Skip to content

Commit b1bbb9a

Browse files
ToolmanPhsiangkao
authored andcommitted
erofs: use kmemdup_nul in erofs_fill_symlink
Remove open coding in erofs_fill_symlink. Suggested-by: Al Viro <[email protected]> Link: https://lore.kernel.org/all/20240425222847.GN2118490@ZenIV Signed-off-by: Yiyang Wu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Gao Xiang <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]>
1 parent 0d442ce commit b1bbb9a

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

fs/erofs/inode.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ static int erofs_fill_symlink(struct inode *inode, void *kaddr,
179179
{
180180
struct erofs_inode *vi = EROFS_I(inode);
181181
loff_t off;
182-
char *lnk;
183182

184183
m_pofs += vi->xattr_isize;
185184
/* check if it cannot be handled with fast symlink scheme */
@@ -190,14 +189,9 @@ static int erofs_fill_symlink(struct inode *inode, void *kaddr,
190189
return 0;
191190
}
192191

193-
lnk = kmalloc(inode->i_size + 1, GFP_KERNEL);
194-
if (!lnk)
192+
inode->i_link = kmemdup_nul(kaddr + m_pofs, inode->i_size, GFP_KERNEL);
193+
if (!inode->i_link)
195194
return -ENOMEM;
196-
197-
memcpy(lnk, kaddr + m_pofs, inode->i_size);
198-
lnk[inode->i_size] = '\0';
199-
200-
inode->i_link = lnk;
201195
inode->i_op = &erofs_fast_symlink_iops;
202196
return 0;
203197
}

0 commit comments

Comments
 (0)