smatch warnings: mm/khugepaged.c:2409 madvise_collapse() warn: possible memory leak of 'cc' Link: https://lore.kernel.org/linux-mm/202207100715.TBIYQ4fc-lkp@xxxxxxxxx/ Link: https://lore.kernel.org/linux-mm/20220713024109.62810-1-jrdr.linux@xxxxxxxxx/ Fixes: 3f7416127072 ("mm/madvise: introduce MADV_COLLAPSE sync hugepage collapse") Reported-by: kernel test robot <lkp@xxxxxxxxx> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Signed-off-by: Zach O'Keefe <zokeefe@xxxxxxxxxx> --- This is in addition to the patch submitted by "Souptick Joarder (HPE)" <jrdr.linux@xxxxxxxxx>: "mm/khugepaged: Avoid possible memory leak in failure path" --- mm/khugepaged.c | 1 + 1 file changed, 1 insertion(+) 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); -- 2.37.0.144.g8ac04bfd2-goog