summaryrefslogtreecommitdiff
path: root/fs/erofs
diff options
context:
space:
mode:
authorYiyang Wu <toolmanp@tlmp.cc>2024-09-02 16:31:46 +0800
committerGao Xiang <hsiangkao@linux.alibaba.com>2024-09-10 15:27:11 +0800
commitb1bbb9a637a329873e14b596b7e6fa2fd44b87b4 (patch)
treeec1c68a51ec4b83a23022498d3454417390a41eb /fs/erofs
parent0d442ce0b3027e99491520a3a8585e8c4ffd79dc (diff)
erofs: use kmemdup_nul in erofs_fill_symlink
Remove open coding in erofs_fill_symlink. Suggested-by: Al Viro <viro@zeniv.linux.org.uk> Link: https://lore.kernel.org/all/20240425222847.GN2118490@ZenIV Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> Link: https://lore.kernel.org/r/20240902083147.450558-2-toolmanp@tlmp.cc Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Diffstat (limited to 'fs/erofs')
-rw-r--r--fs/erofs/inode.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index b9d57d42a158..4ced52b29f5f 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -179,7 +179,6 @@ static int erofs_fill_symlink(struct inode *inode, void *kaddr,
{
struct erofs_inode *vi = EROFS_I(inode);
loff_t off;
- char *lnk;
m_pofs += vi->xattr_isize;
/* check if it cannot be handled with fast symlink scheme */
@@ -190,14 +189,9 @@ static int erofs_fill_symlink(struct inode *inode, void *kaddr,
return 0;
}
- lnk = kmalloc(inode->i_size + 1, GFP_KERNEL);
- if (!lnk)
+ inode->i_link = kmemdup_nul(kaddr + m_pofs, inode->i_size, GFP_KERNEL);
+ if (!inode->i_link)
return -ENOMEM;
-
- memcpy(lnk, kaddr + m_pofs, inode->i_size);
- lnk[inode->i_size] = '\0';
-
- inode->i_link = lnk;
inode->i_op = &erofs_fast_symlink_iops;
return 0;
}