[PATCH v3] erofs-utils: fix memory leak when erofs_fill_inode() fails

Gao Xiang hsiangkao at redhat.com
Fri Jan 22 13:00:04 AEDT 2021


On Fri, Jan 22, 2021 at 12:21:01AM +0800, Hu Weiwen wrote:
> Signed-off-by: Hu Weiwen <sehuww at mail.scut.edu.cn>

Reviewed-by: Gao Xiang <hsiangkao at aol.com>

Thanks,
Gao Xiang

> ---
>  lib/inode.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/inode.c b/lib/inode.c
> index d6a64cc..73a7e69 100644
> --- a/lib/inode.c
> +++ b/lib/inode.c
> @@ -867,8 +867,10 @@ struct erofs_inode *erofs_iget_from_path(const char *path, bool is_src)
>  		return inode;
>  
>  	ret = erofs_fill_inode(inode, &st, path);
> -	if (ret)
> +	if (ret) {
> +		free(inode);
>  		return ERR_PTR(ret);
> +	}
>  
>  	return inode;
>  }
> -- 
> 2.30.0
> 



More information about the Linux-erofs mailing list