* [PATCH] mm/mmap: Fix leak on expand_downwards() and expand_upwards()
@ 2022-05-12 17:59 Liam Howlett
0 siblings, 0 replies; only message in thread
From: Liam Howlett @ 2022-05-12 17:59 UTC (permalink / raw)
To: maple-tree@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Andrew Morton
Cc: Qian Cai
A memory leak is possible in the race and error path in both
expand_downwards() and expand_upwards() due to the maple tree
preallocations. Fix these by always destroying the maple state.
Fixes: a760774e7b7b (mm: start tracking VMAs with maple tree)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
mm/mmap.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/mmap.c b/mm/mmap.c
index c147d2b5550b..ebfd71a79814 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2047,6 +2047,7 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
}
anon_vma_unlock_write(vma->anon_vma);
khugepaged_enter_vma_merge(vma, vma->vm_flags);
+ mas_destroy(&mas);
return error;
}
#endif /* CONFIG_STACK_GROWSUP || CONFIG_IA64 */
@@ -2128,6 +2129,7 @@ int expand_downwards(struct vm_area_struct *vma, unsigned long address)
}
anon_vma_unlock_write(vma->anon_vma);
khugepaged_enter_vma_merge(vma, vma->vm_flags);
+ mas_destroy(&mas);
return error;
}
--
2.35.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-12 17:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-12 17:59 [PATCH] mm/mmap: Fix leak on expand_downwards() and expand_upwards() Liam Howlett
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).