Skip to content

Commit

Permalink
erofs: fix missing unmap if z_erofs_get_extent_compressedlen() fails
Browse files Browse the repository at this point in the history
[ Upstream commit d5d188b ]

Otherwise, meta buffers could be leaked.

Fixes: cec6e93 ("erofs: support parsing big pcluster compress indexes")
Reviewed-by: Yue Hu <huyue2@coolpad.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20221205150050.47784-1-hsiangkao@linux.alibaba.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
hsiangkao authored and gregkh committed Dec 31, 2022
1 parent 618e712 commit 373b6f3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions fs/erofs/zmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down

0 comments on commit 373b6f3

Please sign in to comment.