[PATCH 2/2] erofs: use kmemdup_nul in erofs_fill_symlink
Gao Xiang
hsiangkao at linux.alibaba.com
Mon Sep 2 15:46:44 AEST 2024
Hi Yiyang,
On 2024/9/2 12:51, Yiyang Wu wrote:
> Remove open coding in erofs_fill_symlink.
>
> Suggested-by: Al Viro <viro at zeniv.linux.org.uk>
> Link: https://lore.kernel.org/all/20240425222847.GN2118490@ZenIV
> Signed-off-by: Yiyang Wu <toolmanp at tlmp.cc>
Could we lift this patch as [PATCH 1/2]?
> ---
> fs/erofs/inode.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
> index 90f1235dc404..f435752143cb 100644
> --- a/fs/erofs/inode.c
> +++ b/fs/erofs/inode.c
> @@ -21,23 +21,20 @@ static int erofs_fill_symlink(struct inode *inode, void *kaddr,
> return 0;
> }
>
> - lnk = kmalloc(inode->i_size + 1, GFP_KERNEL);
> - if (!lnk)
> - return -ENOMEM;
> -
> m_pofs += vi->xattr_isize;
> +
> /* inline symlink data shouldn't cross block boundary */
> if (m_pofs + inode->i_size > bsz) {
> - kfree(lnk);
> erofs_err(inode->i_sb,
> "inline data cross block boundary @ nid %llu",
> vi->nid);
> DBG_BUGON(1);
> return -EFSCORRUPTED;
> }
> - memcpy(lnk, kaddr + m_pofs, inode->i_size);
> - lnk[inode->i_size] = '\0';
>
> + lnk = kmemdup_nul(kaddr+m_pofs, inode->i_size, GFP_KERNEL);
lnk = kmemdup_nul(kaddr + m_pofs, inode->i_size, GFP_KERNEL);
Missing blank here.
Thanks,
Gao Xiang
More information about the Linux-erofs
mailing list