]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
f2fs: return errors right after checking them
authorJaegeuk Kim <jaegeuk.kim@samsung.com>
Wed, 23 Apr 2014 03:28:18 +0000 (12:28 +0900)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Wed, 7 May 2014 01:21:56 +0000 (10:21 +0900)
This patch adds two error conditions early in the setxattr operations.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
fs/f2fs/xattr.c

index bbe9c2badf5d5c217ff0fd58cecd8802d2f3ff0e..6073f9f884162d225fe0fe1e8a2e8cf0a2dbc4b5 100644 (file)
@@ -509,8 +509,16 @@ static int __f2fs_setxattr(struct inode *inode, int index,
        here = __find_xattr(base_addr, index, len, name);
 
        found = IS_XATTR_LAST_ENTRY(here) ? 0 : 1;
-       last = here;
 
+       if ((flags & XATTR_REPLACE) && !found) {
+               error = -ENODATA;
+               goto exit;
+       } else if ((flags & XATTR_CREATE) && found) {
+               error = -EEXIST;
+               goto exit;
+       }
+
+       last = here;
        while (!IS_XATTR_LAST_ENTRY(last))
                last = XATTR_NEXT_ENTRY(last);