Commit 772b3140 authored by Daniel Xu's avatar Daniel Xu Committed by Tejun Heo

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: 0c47383b ("kernfs: Add option to enable user xattrs")
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarDaniel Xu <dxu@dxuuu.xyz>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent d8ef4b38
...@@ -876,6 +876,9 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name, ...@@ -876,6 +876,9 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
struct simple_xattr *new_xattr = NULL; struct simple_xattr *new_xattr = NULL;
int err = 0; int err = 0;
if (removed_size)
*removed_size = -1;
/* value == NULL means remove */ /* value == NULL means remove */
if (value) { if (value) {
new_xattr = simple_xattr_alloc(value, size); new_xattr = simple_xattr_alloc(value, size);
...@@ -914,9 +917,6 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name, ...@@ -914,9 +917,6 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
list_add(&new_xattr->list, &xattrs->head); list_add(&new_xattr->list, &xattrs->head);
xattr = NULL; xattr = NULL;
} }
if (removed_size)
*removed_size = -1;
out: out:
spin_unlock(&xattrs->lock); spin_unlock(&xattrs->lock);
if (xattr) { if (xattr) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment