Commit b1bbb9a6 authored by Yiyang Wu's avatar Yiyang Wu Committed by Gao Xiang

erofs: use kmemdup_nul in erofs_fill_symlink

Remove open coding in erofs_fill_symlink.
Suggested-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/all/20240425222847.GN2118490@ZenIVSigned-off-by: default avatarYiyang Wu <toolmanp@tlmp.cc>
Link: https://lore.kernel.org/r/20240902083147.450558-2-toolmanp@tlmp.ccReviewed-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
parent 0d442ce0
......@@ -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;
}
......
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