Skip to content

Commit 3bef735

Browse files
cgxu519torvalds
authored andcommitted
vfs/xattr: mm/shmem: kernfs: release simple xattr entry in a right way
After commit fdc8522 ("kernfs: kvmalloc xattr value instead of kmalloc"), simple xattr entry is allocated with kvmalloc() instead of kmalloc(), so we should release it with kvfree() instead of kfree(). Fixes: fdc8522 ("kernfs: kvmalloc xattr value instead of kmalloc") Signed-off-by: Chengguang Xu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Acked-by: Hugh Dickins <[email protected]> Acked-by: Tejun Heo <[email protected]> Cc: Daniel Xu <[email protected]> Cc: Chris Down <[email protected]> Cc: Andreas Dilger <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Al Viro <[email protected]> Cc: <[email protected]> [5.7] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 246c320 commit 3bef735

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

include/linux/xattr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/slab.h>
1616
#include <linux/types.h>
1717
#include <linux/spinlock.h>
18+
#include <linux/mm.h>
1819
#include <uapi/linux/xattr.h>
1920

2021
struct inode;
@@ -94,7 +95,7 @@ static inline void simple_xattrs_free(struct simple_xattrs *xattrs)
9495

9596
list_for_each_entry_safe(xattr, node, &xattrs->head, list) {
9697
kfree(xattr->name);
97-
kfree(xattr);
98+
kvfree(xattr);
9899
}
99100
}
100101

mm/shmem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3178,7 +3178,7 @@ static int shmem_initxattrs(struct inode *inode,
31783178
new_xattr->name = kmalloc(XATTR_SECURITY_PREFIX_LEN + len,
31793179
GFP_KERNEL);
31803180
if (!new_xattr->name) {
3181-
kfree(new_xattr);
3181+
kvfree(new_xattr);
31823182
return -ENOMEM;
31833183
}
31843184

0 commit comments

Comments
 (0)