mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-06 09:25:22 +02:00
FROMGIT: erofs: fix possible memory leak in z_erofs_gbuf_exit()
Because we incorrectly reused of variable `i` in `z_erofs_gbuf_exit()`
for inner loop, we may exit early from outer loop resulting in memory
leak. Fix this by using separate variable for iterating through inner loop.
Bug: 348591003
Change-Id: I2dee8555af6cad36ed8c9b6d818f1d2a5cb75458
Fixes: f36f3010f6
("erofs: rename per-CPU buffers to global buffer pool and make it configurable")
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240624220206.3373197-1-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
(cherry picked from commit e41f107428237224fd51d99a4dc4358aba3b7d5f
https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git dev-test)
Signed-off-by: Chunhai Guo <guochunhai@vivo.com>
This commit is contained in:
parent
412548f4e6
commit
aca2287a01
|
@ -147,7 +147,7 @@ int __init z_erofs_gbuf_init(void)
|
|||
|
||||
void z_erofs_gbuf_exit(void)
|
||||
{
|
||||
int i;
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < z_erofs_gbuf_count + (!!z_erofs_rsvbuf); ++i) {
|
||||
struct z_erofs_gbuf *gbuf = &z_erofs_gbufpool[i];
|
||||
|
@ -160,9 +160,9 @@ void z_erofs_gbuf_exit(void)
|
|||
if (!gbuf->pages)
|
||||
continue;
|
||||
|
||||
for (i = 0; i < gbuf->nrpages; ++i)
|
||||
if (gbuf->pages[i])
|
||||
put_page(gbuf->pages[i]);
|
||||
for (j = 0; j < gbuf->nrpages; ++j)
|
||||
if (gbuf->pages[j])
|
||||
put_page(gbuf->pages[j]);
|
||||
kfree(gbuf->pages);
|
||||
gbuf->pages = NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user