diff mbox series

[5/9] mm: kmemleak: do not scan sparsemap_buf

Message ID 20230123170419.7292-6-george@enfabrica.net (mailing list archive)
State New
Headers show
Series mm: kmemleak: fix unreported memory leaks | expand

Commit Message

George Prekas Jan. 23, 2023, 5:04 p.m. UTC
sparsemap_buf is used for vmemmap and vmemmap contains an array of
struct page. kmemleak scans the pages separately. If it scans them
twice, then it will duplicate the number of found references and will
cause missed leaks.

Signed-off-by: George Prekas <george@enfabrica.net>
---
 mm/sparse.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/mm/sparse.c b/mm/sparse.c
index 2779b419ef2a..49df7a052037 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -14,6 +14,7 @@ 
 #include <linux/swap.h>
 #include <linux/swapops.h>
 #include <linux/bootmem_info.h>
+#include <linux/kmemleak.h>
 
 #include "internal.h"
 #include <asm/dma.h>
@@ -466,6 +467,8 @@  static void __init sparse_buffer_init(unsigned long size, int nid)
 	 */
 	sparsemap_buf = memmap_alloc(size, section_map_size(), addr, nid, true);
 	sparsemap_buf_end = sparsemap_buf + size;
+	/* sparsemap_buf has been registered with its physical address in kmemleak */
+	kmemleak_no_scan_phys(virt_to_phys(sparsemap_buf));
 }
 
 static void __init sparse_buffer_fini(void)