Skip to contentSkip to conversation

mm-damon-lru_sort-fix-potential-memory-leak-in-damon_lru_sort_init.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Jul 18, 2022

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/damon/lru_sort: fix potential memory leak in damon_lru_sort_init()
has been removed from the -mm tree. Its filename was
mm-damon-lru_sort-fix-potential-memory-leak-in-damon_lru_sort_init.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: SeongJae Park <[email protected]>
Subject: mm/damon/lru_sort: fix potential memory leak in damon_lru_sort_init()
Date: Thu, 14 Jul 2022 17:04:58 +0000

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.

Fixes 40e983cca927 ("mm/damon: introduce DAMON-based LRU-lists Sorting")

---

 mm/damon/lru_sort.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
mm/damon/lru_sort.c renamed from mm/damon/lru_sort.c~mm-damon-lru_sort-fix-potential-memory-leak-in-damon_lru_sort_init +3 -1
@@ -524,8 +524,10 @@ static int __init damon_lru_sort_init(vo
 	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;

_

Patches currently in -mm which might be from [email protected] are