mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
mm/damon/lru_sort: fix potential memory leak in damon_lru_sort_init()
damon_lru_sort_init() returns an error when damon_select_ops() fails
without freeing 'ctx' which allocated before. This commit fixes the
potential memory leak by freeing 'ctx' under the situation.
Link: https://lkml.kernel.org/r/20220714170458.49727-1-sj@kernel.org
Fixes: 40e983cca9
("mm/damon: introduce DAMON-based LRU-lists Sorting")
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
4f2930c671
commit
ec1658f0f9
@ -524,8 +524,10 @@ static int __init damon_lru_sort_init(void)
|
||||
if (!ctx)
|
||||
return -ENOMEM;
|
||||
|
||||
if (damon_select_ops(ctx, DAMON_OPS_PADDR))
|
||||
if (damon_select_ops(ctx, DAMON_OPS_PADDR)) {
|
||||
damon_destroy_ctx(ctx);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx->callback.after_wmarks_check = damon_lru_sort_after_wmarks_check;
|
||||
ctx->callback.after_aggregation = damon_lru_sort_after_aggregation;
|
||||
|
Loading…
Reference in New Issue
Block a user