From: Gao Xiang Date: Mon, 5 Dec 2022 15:00:49 +0000 (+0800) Subject: erofs: fix missing unmap if z_erofs_get_extent_compressedlen() fails X-Git-Tag: v6.1.8~1787 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=373b6f350aecf5dca2e7474f0b4ec8cca659f2f0;p=platform%2Fkernel%2Flinux-starfive.git erofs: fix missing unmap if z_erofs_get_extent_compressedlen() fails [ Upstream commit d5d188b8f8b38d3d71dd05993874b4fc9284ce95 ] Otherwise, meta buffers could be leaked. Fixes: cec6e93beadf ("erofs: support parsing big pcluster compress indexes") Reviewed-by: Yue Hu Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Link: https://lore.kernel.org/r/20221205150050.47784-1-hsiangkao@linux.alibaba.com Signed-off-by: Sasha Levin --- diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c index 0bb6692..f49295b 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; }