diff mbox series

[mm-unstable] mm/khugepaged: add missing kfree() to madvise_collapse()

Message ID 20220713161851.1879439-1-zokeefe@google.com (mailing list archive)
State New
Headers show
Series [mm-unstable] mm/khugepaged: add missing kfree() to madvise_collapse() | expand

Commit Message

Zach O'Keefe July 13, 2022, 4:18 p.m. UTC
smatch warnings:
mm/khugepaged.c:2409 madvise_collapse() warn: possible memory leak of
'cc'

Link: https://lore.kernel.org/linux-mm/202207100715.TBIYQ4fc-lkp@intel.com/
Link: https://lore.kernel.org/linux-mm/20220713024109.62810-1-jrdr.linux@gmail.com/
Fixes: 3f7416127072 ("mm/madvise: introduce MADV_COLLAPSE sync hugepage collapse")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Zach O'Keefe <zokeefe@google.com>

---
This is in addition to the patch submitted by "Souptick Joarder (HPE)"
<jrdr.linux@gmail.com>:  "mm/khugepaged: Avoid possible memory leak in failure path"

---
 mm/khugepaged.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 0207fc0a5b2a..944cf6c8a252 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2472,6 +2472,7 @@  int madvise_collapse(struct vm_area_struct *vma, struct vm_area_struct **prev,
 out_nolock:
 	mmap_assert_locked(mm);
 	mmdrop(mm);
+	kfree(cc);
 
 	return thps == ((hend - hstart) >> HPAGE_PMD_SHIFT) ? 0
 			: madvise_collapse_errno(last_fail);