Skip to content

Commit 772b314

Browse files
danobihtejun
authored andcommitted
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: 0c47383 ("kernfs: Add option to enable user xattrs") Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Daniel Xu <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent d8ef4b3 commit 772b314

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/xattr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,9 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
876876
struct simple_xattr *new_xattr = NULL;
877877
int err = 0;
878878

879+
if (removed_size)
880+
*removed_size = -1;
881+
879882
/* value == NULL means remove */
880883
if (value) {
881884
new_xattr = simple_xattr_alloc(value, size);
@@ -914,9 +917,6 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
914917
list_add(&new_xattr->list, &xattrs->head);
915918
xattr = NULL;
916919
}
917-
918-
if (removed_size)
919-
*removed_size = -1;
920920
out:
921921
spin_unlock(&xattrs->lock);
922922
if (xattr) {

0 commit comments

Comments
 (0)