Commit add70aae authored by Liu Shixin's avatar Liu Shixin
Browse files

bootmem: remove the vmemmap pages from kmemleak in free_bootmem_page

mainline inclusion
from mainline-v6.7-rc1
commit 80203f1ca086835100843f1474bd6dd4a48cc73b
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAR7B3

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=80203f1ca086835100843f1474bd6dd4a48cc73b

--------------------------------

commit dd0ff4d1 ("bootmem: remove the vmemmap pages from kmemleak in
put_page_bootmem") fix an overlaps existing problem of kmemleak.  But the
problem still existed when HAVE_BOOTMEM_INFO_NODE is disabled, because in
this case, free_bootmem_page() will call free_reserved_page() directly.

Fix the problem by adding kmemleak_free_part() in free_bootmem_page() when
HAVE_BOOTMEM_INFO_NODE is disabled.

Link: https://lkml.kernel.org/r/20230704101942.2819426-1-liushixin2@huawei.com


Fixes: f41f2ed4 ("mm: hugetlb: free the vmemmap pages associated with each HugeTLB page")
Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
Acked-by: default avatarMuchun Song <songmuchun@bytedance.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
parent 992ba0c8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
#define __LINUX_BOOTMEM_INFO_H

#include <linux/mm.h>
#include <linux/kmemleak.h>

/*
 * Types for free bootmem stored in page->lru.next. These have to be in
@@ -59,6 +60,7 @@ static inline void get_page_bootmem(unsigned long info, struct page *page,

static inline void free_bootmem_page(struct page *page)
{
	kmemleak_free_part(page_to_virt(page), PAGE_SIZE);
	free_reserved_page(page);
}
#endif