aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2009-09-25 02:32:58 -0400
committerRusty Russell <rusty@rustcorp.com.au>2009-09-24 11:02:59 -0400
commita263f7763c364015f92e7c097fa46c6673f6fcb0 (patch)
tree3fecc1a81f60ef71bc59c751f298496f9b0b1da6 /kernel
parent1d7015caa082d465faeae5d6fd1be077ee6dfa87 (diff)
module: fix memory leak when load fails after srcversion/version allocated
Normally the twisty paths of sysfs will free the attributes, but not if we fail before we hook it into sysfs (which is the last thing we do in load_module). (This sysfs code is a turd, no doubt there are other issues lurking too). Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Cc: Catalin Marinas <catalin.marinas@arm.com> Tested-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/module.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 39827c3d9484..c54f10d90e1c 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1797,6 +1797,17 @@ static void setup_modinfo(struct module *mod, Elf_Shdr *sechdrs,
1797 } 1797 }
1798} 1798}
1799 1799
1800static void free_modinfo(struct module *mod)
1801{
1802 struct module_attribute *attr;
1803 int i;
1804
1805 for (i = 0; (attr = modinfo_attrs[i]); i++) {
1806 if (attr->free)
1807 attr->free(mod);
1808 }
1809}
1810
1800#ifdef CONFIG_KALLSYMS 1811#ifdef CONFIG_KALLSYMS
1801 1812
1802/* lookup symbol in given range of kernel_symbols */ 1813/* lookup symbol in given range of kernel_symbols */
@@ -2506,6 +2517,7 @@ static noinline struct module *load_module(void __user *umod,
2506 synchronize_sched(); 2517 synchronize_sched();
2507 module_arch_cleanup(mod); 2518 module_arch_cleanup(mod);
2508 cleanup: 2519 cleanup:
2520 free_modinfo(mod);
2509 kobject_del(&mod->mkobj.kobj); 2521 kobject_del(&mod->mkobj.kobj);
2510 kobject_put(&mod->mkobj.kobj); 2522 kobject_put(&mod->mkobj.kobj);
2511 free_unload: 2523 free_unload: