[Devel] [PATCH] module: fix memory leak in free_module

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Tue Jul 25 16:54:52 MSK 2017


Reported by kmemleak:

  comm "systemd-udevd", pid 436, jiffies 4294689313 (age 1166.192s)
  hex dump (first 32 bytes):
    00 01 00 00 00 00 ad de 00 02 00 00 00 00 ad de  ................
    80 c1 55 a0 ff ff ff ff 00 00 00 00 00 00 00 00  ..U.............
  backtrace:
    [<ffffffff8167886e>] kmemleak_alloc+0x4e/0xb0
    [<ffffffff811f29f9>] kmem_cache_alloc_trace+0xe9/0x260
    [<ffffffff8110e10e>] load_module+0x35e/0x1be0
    [<ffffffff8110fb36>] SyS_finit_module+0xa6/0xd0
    [<ffffffff81694a89>] system_call_fastpath+0x16/0x1b
    [<ffffffffffffffff>] 0xffffffffffffffff

Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
 kernel/module.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/module.c b/kernel/module.c
index ebf89f4..27664bd1 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1986,6 +1986,7 @@ static void free_module(struct module *mod)
 	mod_ext = find_module_ext(mod);
 	list_del(&mod_ext->next);
 	mutex_unlock(&module_ext_mutex);
+	kfree(mod_ext);
 
 	/* This may be NULL, but that's OK */
 	unset_module_init_ro_nx(mod);



More information about the Devel mailing list