Commit 2a6a7e72 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: fix to use kvfree instead of kzfree

As Jiqun Li reported in bugzilla:

https://bugzilla.kernel.org/show_bug.cgi?id=202747

System can panic due to using wrong allocate/free function pair
in xattr interface:
- use kvmalloc to allocate memory
- use kzfree to free memory

Let's fix to use kvfree instead of kzfree, BTW, we are safe to
get rid of kzfree, since there is no such confidential data stored
as xattr, we don't need to zero it before free memory.

Fixes: 5222595d ("f2fs: use kvmalloc, if kmalloc is failed")
Reported-by: default avatarJiqun Li <jiqun.li@unisoc.com>
Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 76630f20
...@@ -340,7 +340,7 @@ static int lookup_all_xattrs(struct inode *inode, struct page *ipage, ...@@ -340,7 +340,7 @@ static int lookup_all_xattrs(struct inode *inode, struct page *ipage,
*base_addr = txattr_addr; *base_addr = txattr_addr;
return 0; return 0;
out: out:
kzfree(txattr_addr); kvfree(txattr_addr);
return err; return err;
} }
...@@ -383,7 +383,7 @@ static int read_all_xattrs(struct inode *inode, struct page *ipage, ...@@ -383,7 +383,7 @@ static int read_all_xattrs(struct inode *inode, struct page *ipage,
*base_addr = txattr_addr; *base_addr = txattr_addr;
return 0; return 0;
fail: fail:
kzfree(txattr_addr); kvfree(txattr_addr);
return err; return err;
} }
...@@ -510,7 +510,7 @@ int f2fs_getxattr(struct inode *inode, int index, const char *name, ...@@ -510,7 +510,7 @@ int f2fs_getxattr(struct inode *inode, int index, const char *name,
} }
error = size; error = size;
out: out:
kzfree(base_addr); kvfree(base_addr);
return error; return error;
} }
...@@ -556,7 +556,7 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) ...@@ -556,7 +556,7 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
} }
error = buffer_size - rest; error = buffer_size - rest;
cleanup: cleanup:
kzfree(base_addr); kvfree(base_addr);
return error; return error;
} }
...@@ -687,7 +687,7 @@ static int __f2fs_setxattr(struct inode *inode, int index, ...@@ -687,7 +687,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
if (!error && S_ISDIR(inode->i_mode)) if (!error && S_ISDIR(inode->i_mode))
set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_CP); set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_CP);
exit: exit:
kzfree(base_addr); kvfree(base_addr);
return error; return error;
} }
......
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