瀏覽代碼

f2fs: return errors right after checking them

This patch adds two error conditions early in the setxattr operations.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Jaegeuk Kim 11 年之前
父節點
當前提交
916decbf39
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9 1
      fs/f2fs/xattr.c

+ 9 - 1
fs/f2fs/xattr.c

@@ -509,8 +509,16 @@ static int __f2fs_setxattr(struct inode *inode, int index,
 	here = __find_xattr(base_addr, index, len, name);
 	here = __find_xattr(base_addr, index, len, name);
 
 
 	found = IS_XATTR_LAST_ENTRY(here) ? 0 : 1;
 	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))
 	while (!IS_XATTR_LAST_ENTRY(last))
 		last = XATTR_NEXT_ENTRY(last);
 		last = XATTR_NEXT_ENTRY(last);