2022-12-05 15:40:04

by Gao Xiang

[permalink] [raw]
Subject: [PATCH 1/2] erofs: fix missing unmap if z_erofs_get_extent_compressedlen() fails

Otherwise, meta buffers could be leaked.

Fixes: cec6e93beadf ("erofs: support parsing big pcluster compress indexes")
Signed-off-by: Gao Xiang <[email protected]>
---
fs/erofs/zmap.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
index 749a5ac943f4..98eff1259de4 100644
--- a/fs/erofs/zmap.c
+++ b/fs/erofs/zmap.c
@@ -694,7 +694,7 @@ static int z_erofs_do_map_blocks(struct inode *inode,
map->m_pa = blknr_to_addr(m.pblk);
err = z_erofs_get_extent_compressedlen(&m, initial_lcn);
if (err)
- goto out;
+ goto unmap_out;
}

if (m.headtype == Z_EROFS_VLE_CLUSTER_TYPE_PLAIN) {
@@ -718,14 +718,12 @@ static int z_erofs_do_map_blocks(struct inode *inode,
if (!err)
map->m_flags |= EROFS_MAP_FULL_MAPPED;
}
+
unmap_out:
erofs_unmap_metabuf(&m.map->buf);
-
-out:
erofs_dbg("%s, m_la %llu m_pa %llu m_llen %llu m_plen %llu m_flags 0%o",
__func__, map->m_la, map->m_pa,
map->m_llen, map->m_plen, map->m_flags);
-
return err;
}

--
2.24.4


2022-12-06 07:14:59

by Yue Hu

[permalink] [raw]
Subject: Re: [PATCH 1/2] erofs: fix missing unmap if z_erofs_get_extent_compressedlen() fails

On Mon, 5 Dec 2022 23:00:49 +0800
Gao Xiang <[email protected]> wrote:

> Otherwise, meta buffers could be leaked.
>
> Fixes: cec6e93beadf ("erofs: support parsing big pcluster compress indexes")
> Signed-off-by: Gao Xiang <[email protected]>

Reviewed-by: Yue Hu <[email protected]>

> ---
> fs/erofs/zmap.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
> index 749a5ac943f4..98eff1259de4 100644
> --- a/fs/erofs/zmap.c
> +++ b/fs/erofs/zmap.c
> @@ -694,7 +694,7 @@ static int z_erofs_do_map_blocks(struct inode *inode,
> map->m_pa = blknr_to_addr(m.pblk);
> err = z_erofs_get_extent_compressedlen(&m, initial_lcn);
> if (err)
> - goto out;
> + goto unmap_out;
> }
>
> if (m.headtype == Z_EROFS_VLE_CLUSTER_TYPE_PLAIN) {
> @@ -718,14 +718,12 @@ static int z_erofs_do_map_blocks(struct inode *inode,
> if (!err)
> map->m_flags |= EROFS_MAP_FULL_MAPPED;
> }
> +
> unmap_out:
> erofs_unmap_metabuf(&m.map->buf);
> -
> -out:
> erofs_dbg("%s, m_la %llu m_pa %llu m_llen %llu m_plen %llu m_flags 0%o",
> __func__, map->m_la, map->m_pa,
> map->m_llen, map->m_plen, map->m_flags);
> -
> return err;
> }
>

2022-12-06 15:32:56

by Chao Yu

[permalink] [raw]
Subject: Re: [PATCH 1/2] erofs: fix missing unmap if z_erofs_get_extent_compressedlen() fails

On 2022/12/5 23:00, Gao Xiang wrote:
> Otherwise, meta buffers could be leaked.
>
> Fixes: cec6e93beadf ("erofs: support parsing big pcluster compress indexes")
> Signed-off-by: Gao Xiang <[email protected]>

Reviewed-by: Chao Yu <[email protected]>

Thanks,