lkml.org 
[lkml]   [2009]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [2.6.31] Memory leak in load_module()?
Date
On Fri, 11 Sep 2009 05:08:46 pm Tetsuo Handa wrote:
> Is this real memory leak?

Yep.

God, this code is a turd. This should fix it though:

diff --git a/kernel/module.c b/kernel/module.c
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1907,6 +1924,17 @@ static void setup_modinfo(struct module
}
}

+static void free_modinfo(struct module *mod)
+{
+ struct module_attribute *attr;
+ int i;
+
+ for (i = 0; (attr = modinfo_attrs[i]); i++) {
+ if (attr->free)
+ attr->free(mod);
+ }
+}
+
#ifdef CONFIG_KALLSYMS

/* lookup symbol in given range of kernel_symbols */
@@ -2632,6 +2662,7 @@ static noinline struct module *load_modu
synchronize_sched();
module_arch_cleanup(mod);
cleanup:
+ free_modinfo(mod);
kobject_del(&mod->mkobj.kobj);
kobject_put(&mod->mkobj.kobj);
free_unload:

\
 
 \ /
  Last update: 2009-09-22 04:33    [W:0.096 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site