[PATCH] erofs: avoid useless memory allocation
Gao Xiang
hsiangkao at linux.alibaba.com
Fri Mar 3 18:59:30 AEDT 2023
On 2023/3/3 15:52, Noboru Asai wrote:
> The variable 'vi->xattr_shared_count' could be ZERO.
>
> Signed-off-by: Noboru Asai <asai at sijam.com>
Reviewed-by: Gao Xiang <hsiangkao at linux.alibaba.com>
Thanks,
Gao Xiang
> ---
> fs/erofs/xattr.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
> index 60729b1220b6..5164813a693b 100644
> --- a/fs/erofs/xattr.c
> +++ b/fs/erofs/xattr.c
> @@ -80,6 +80,8 @@ static int init_inode_xattrs(struct inode *inode)
>
> ih = (struct erofs_xattr_ibody_header *)(it.kaddr + it.ofs);
> vi->xattr_shared_count = ih->h_shared_count;
> + if (!vi->xattr_shared_count)
> + goto out_unlock;
> vi->xattr_shared_xattrs = kmalloc_array(vi->xattr_shared_count,
> sizeof(uint), GFP_KERNEL);
> if (!vi->xattr_shared_xattrs) {
More information about the Linux-erofs
mailing list