1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Module kmemleak support
5 * Copyright (C) 2009 Catalin Marinas
8 #include <linux/module.h>
9 #include <linux/kmemleak.h>
12 void kmemleak_load_module(const struct module *mod,
13 const struct load_info *info)
17 /* only scan the sections containing data */
18 kmemleak_scan_area(mod, sizeof(struct module), GFP_KERNEL);
20 for (i = 1; i < info->hdr->e_shnum; i++) {
21 /* Scan all writable sections that's not executable */
22 if (!(info->sechdrs[i].sh_flags & SHF_ALLOC) ||
23 !(info->sechdrs[i].sh_flags & SHF_WRITE) ||
24 (info->sechdrs[i].sh_flags & SHF_EXECINSTR))
27 kmemleak_scan_area((void *)info->sechdrs[i].sh_addr,
28 info->sechdrs[i].sh_size, GFP_KERNEL);