[PATCH] uerofs-utils: fix random data for block-aligned uncompressed file

Gao Xiang xiang at kernel.org
Tue Sep 7 10:10:45 AEST 2021


On Mon, Sep 06, 2021 at 04:13:59PM +0800, Huang Jianan via Linux-erofs wrote:
> If the file size is block-aligned for uncompressed files, i_u is
> meaningless for erofs_inode on disk, but it's not cleared when
> datalayout is seted in erofs_prepare_inode_buffer. Clear the entire
> erofs_inode to zero to fix this.
> 
> Signed-off-by: Huang Jianan <huangjianan at oppo.com>
> ---
>  lib/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/inode.c b/lib/inode.c
> index 0ad703d..1397cc5 100644
> --- a/lib/inode.c
> +++ b/lib/inode.c
> @@ -834,7 +834,7 @@ static struct erofs_inode *erofs_new_inode(void)
>  	static unsigned int counter;
>  	struct erofs_inode *inode;
>  
> -	inode = malloc(sizeof(struct erofs_inode));
> +	inode = calloc(1, sizeof(struct erofs_inode));

If we decide to do this, how about removing all
	inode->idata_size = 0;
	inode->xattr_isize = 0;
	inode->extent_isize = 0;

	inode->bh = inode->bh_inline = inode->bh_data = NULL;
	inode->idata = NULL;
?

Thanks,
Gao Xiang

>  	if (!inode)
>  		return ERR_PTR(-ENOMEM);
>  
> -- 
> 2.25.1
> 


More information about the Linux-erofs mailing list