Skip to content

Commit

Permalink
erofs: fix memory leak on short-lived bounced pages
Browse files Browse the repository at this point in the history
Both MicroLZMA and DEFLATE algorithms can use short-lived pages on
demand for the overlapped inplace I/O decompression.

However, those short-lived pages are actually added to
`be->compressed_pages`.  Thus, it should be checked instead of
`pcl->compressed_bvecs`.

The LZ4 algorithm doesn't work like this, so it won't be impacted.

Fixes: 67139e3 ("erofs: introduce `z_erofs_parse_in_bvecs'")
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/20231128180431.4116991-1-hsiangkao@linux.alibaba.com
  • Loading branch information
hsiangkao committed Dec 14, 2023
1 parent 2cc14f5 commit 93d6fda
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions fs/erofs/zdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,12 +1309,11 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
put_page(page);
} else {
for (i = 0; i < pclusterpages; ++i) {
page = pcl->compressed_bvecs[i].page;
/* consider shortlived pages added when decompressing */
page = be->compressed_pages[i];

if (erofs_page_is_managed(sbi, page))
continue;

/* recycle all individual short-lived pages */
(void)z_erofs_put_shortlivedpage(be->pagepool, page);
WRITE_ONCE(pcl->compressed_bvecs[i].page, NULL);
}
Expand Down

0 comments on commit 93d6fda

Please sign in to comment.