[PATCH] erofs-utils: check the return value of erofs_d_alloc

Yue Hu zbestahu at gmail.com
Thu Nov 18 21:04:23 AEDT 2021


On Wed, 17 Nov 2021 18:21:19 +0800
Huang Jianan via Linux-erofs <linux-erofs at lists.ozlabs.org> wrote:

> Need to check whether the allocation of erofs_dentry is successful.
> 
> Signed-off-by: Huang Jianan <huangjianan at oppo.com>
> ---
>  lib/inode.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/lib/inode.c b/lib/inode.c
> index 5cbfc78..2fa74e2 100644
> --- a/lib/inode.c
> +++ b/lib/inode.c
> @@ -162,11 +162,15 @@ int erofs_prepare_dir_file(struct erofs_inode *dir, unsigned int nr_subdirs)
>  
>  	/* dot is pointed to the current dir inode */
>  	d = erofs_d_alloc(dir, ".");
> +	if (IS_ERR(d))
> +		return PTR_ERR(d);
>  	d->inode = erofs_igrab(dir);
>  	d->type = EROFS_FT_DIR;
>  
>  	/* dotdot is pointed to the parent dir */
>  	d = erofs_d_alloc(dir, "..");
> +	if (IS_ERR(d))
> +		return PTR_ERR(d);
>  	d->inode = erofs_igrab(dir->i_parent);
>  	d->type = EROFS_FT_DIR;
>  

Looks good to me

Reviewed-by: Yue Hu <huyue2 at yulong.com>


More information about the Linux-erofs mailing list