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

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Tue Jul 25 16:36:57 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 dfccff9..ebf89f4 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3519,6 +3519,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
 	mutex_lock(&module_ext_mutex);
 	list_del(&mod_ext->next);
 	mutex_unlock(&module_ext_mutex);
+	kfree(mod_ext);
  free_unload:
 	module_unload_free(mod);
  unlink_mod:



More information about the Devel mailing list