1 From 6b95bfad8187d730a6748ae969d05729925a643b Mon Sep 17 00:00:00 2001
2 From: Chao Yu <yuchao0@huawei.com>
3 Date: Tue, 5 Mar 2019 17:52:33 +0800
4 Subject: f2fs: fix to use kvfree instead of kzfree
6 [ Upstream commit 2a6a7e722e7a78d774ce02b847c5b183a3ff2672 ]
8 As Jiqun Li reported in bugzilla:
10 https://bugzilla.kernel.org/show_bug.cgi?id=202747
12 System can panic due to using wrong allocate/free function pair
14 - use kvmalloc to allocate memory
15 - use kzfree to free memory
17 Let's fix to use kvfree instead of kzfree, BTW, we are safe to
18 get rid of kzfree, since there is no such confidential data stored
19 as xattr, we don't need to zero it before free memory.
21 Fixes: 5222595d093e ("f2fs: use kvmalloc, if kmalloc is failed")
22 Reported-by: Jiqun Li <jiqun.li@unisoc.com>
23 Signed-off-by: Chao Yu <yuchao0@huawei.com>
24 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
25 Signed-off-by: Sasha Levin <sashal@kernel.org>
27 fs/f2fs/xattr.c | 10 +++++-----
28 1 file changed, 5 insertions(+), 5 deletions(-)
30 diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
31 index 73b92985198b..6b6fe6431a64 100644
34 @@ -347,7 +347,7 @@ static int lookup_all_xattrs(struct inode *inode, struct page *ipage,
35 *base_addr = txattr_addr;
38 - kzfree(txattr_addr);
39 + kvfree(txattr_addr);
43 @@ -390,7 +390,7 @@ static int read_all_xattrs(struct inode *inode, struct page *ipage,
44 *base_addr = txattr_addr;
47 - kzfree(txattr_addr);
48 + kvfree(txattr_addr);
52 @@ -517,7 +517,7 @@ int f2fs_getxattr(struct inode *inode, int index, const char *name,
61 @@ -563,7 +563,7 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
63 error = buffer_size - rest;
70 @@ -694,7 +694,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
71 if (!error && S_ISDIR(inode->i_mode))
72 set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_CP);