Skip to contentSkip to conversation

mm-fix-memory-leak-on-mm_init-error-handling.patch removed from -mm tree

merged mm-hotfixes-stable Andrew Morton 1 participant 1 message Apr 18, 2023 Stable branch

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm: fix memory leak on mm_init error handling
has been removed from the -mm tree. Its filename was
mm-fix-memory-leak-on-mm_init-error-handling.patch

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

------------------------------------------------------
From: Mathieu Desnoyers <[email protected]>
Subject: mm: fix memory leak on mm_init error handling
Date: Thu, 30 Mar 2023 09:38:22 -0400

commit f1a7941243c1 ("mm: convert mm's rss stats into percpu_counter") introduces a memory leak by missing a call to destroy_context() when a percpu_counter fails to allocate.

Before introducing the per-cpu counter allocations, init_new_context() was the last call that could fail in mm_init(), and thus there was no need to ever invoke destroy_context() in the error paths. Adding the following percpu counter allocations adds error paths after init_new_context(), which means its associated destroy_context() needs to be called when percpu counters fail to allocate.

Fixes f1a7941243c1 ("mm: convert mm's rss stats into percpu_counter")
Cc Marek Szyprowski <[email protected]>

---

 kernel/fork.c |    1 +
 1 file changed, 1 insertion(+)
kernel/fork.c renamed from kernel/fork.c~mm-fix-memory-leak-on-mm_init-error-handling +1 -0
@@ -1174,6 +1174,7 @@ static struct mm_struct *mm_init(struct
 fail_pcpu:
 	while (i > 0)
 		percpu_counter_destroy(&mm->rss_stat[--i]);
+	destroy_context(mm);
 fail_nocontext:
 	mm_free_pgd(mm);
 fail_nopgd:

_

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