public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH] mm/mempolicy: fix memory leak in weighted_interleave_auto_store()
@ 2026-03-31 10:07 Jackie Liu
  2026-03-31 14:31 ` Joshua Hahn
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jackie Liu @ 2026-03-31 10:07 UTC (permalink / raw)
  To: akpm, joshua.hahnjy; +Cc: linux-mm

From: Jackie Liu <liuyun01@kylinos.cn>

Add the missing kfree(new_wi_state) when the auto mode is already set
to the requested value. When a user writes "false" to the auto sysfs
interface and the current mode is already manual (mode_auto == false),
the function returns early without freeing new_wi_state allocated at
the beginning of the function. This can be triggered repeatedly from
userspace, leaking memory on each write.

Fixes: e341f9c3c841 ("mm/mempolicy: Weighted Interleave Auto-tuning")
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
 mm/mempolicy.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index cf92bd6a8226..9ac74178075b 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -3713,6 +3713,7 @@ static ssize_t weighted_interleave_auto_store(struct kobject *kobj,
 			goto update_wi_state;
 		if (input == old_wi_state->mode_auto) {
 			mutex_unlock(&wi_state_lock);
+			kfree(new_wi_state);
 			return count;
 		}
 
-- 
2.51.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-04-01  0:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31 10:07 [PATCH] mm/mempolicy: fix memory leak in weighted_interleave_auto_store() Jackie Liu
2026-03-31 14:31 ` Joshua Hahn
2026-03-31 16:41 ` Donet Tom
2026-03-31 16:53 ` Gregory Price
2026-03-31 19:01   ` Andrew Morton
2026-03-31 19:21     ` Joshua Hahn
2026-03-31 19:24       ` Joshua Hahn
2026-04-01  0:59       ` Jackie Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox