From: Jaegeuk Kim Date: Wed, 23 Apr 2014 03:28:18 +0000 (+0900) Subject: f2fs: return errors right after checking them X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=916decbf3913ccdc68f0228e001a6d270cf5682e;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git f2fs: return errors right after checking them This patch adds two error conditions early in the setxattr operations. Signed-off-by: Jaegeuk Kim --- diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index bbe9c2badf5d..6073f9f88416 100644 --- a/fs/f2fs/xattr.c +++ b/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); 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);