summaryrefslogtreecommitdiff
path: root/fs/xattr.c
diff options
context:
space:
mode:
authorDaniel Xu <dxu@dxuuu.xyz>2020-04-09 09:27:29 +0300
committerTejun Heo <tj@kernel.org>2020-04-09 22:33:09 +0300
commit772b3140669246e1ab32392c490d338e2eb7b803 (patch)
tree404162cb31bd7fd2afd7e906dac4ce076ad5f6a9 /fs/xattr.c
parentd8ef4b38cb69d907f9b0e889c44d05fc0f890977 (diff)
downloadlinux-772b3140669246e1ab32392c490d338e2eb7b803.tar.xz
xattr: fix uninitialized out-param
`removed_sized` isn't correctly initialized (as the doc comment suggests) on memory allocation failures. Fix by moving initialization up a bit. Fixes: 0c47383ba3bd ("kernfs: Add option to enable user xattrs") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'fs/xattr.c')
-rw-r--r--fs/xattr.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/xattr.c b/fs/xattr.c
index e13265e65871..91608d9bfc6a 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -876,6 +876,9 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
struct simple_xattr *new_xattr = NULL;
int err = 0;
+ if (removed_size)
+ *removed_size = -1;
+
/* value == NULL means remove */
if (value) {
new_xattr = simple_xattr_alloc(value, size);
@@ -914,9 +917,6 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
list_add(&new_xattr->list, &xattrs->head);
xattr = NULL;
}
-
- if (removed_size)
- *removed_size = -1;
out:
spin_unlock(&xattrs->lock);
if (xattr) {