提交 a263f776 编写于 作者: R Rusty Russell

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: NTetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Tested-by: NTetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
上级 1d7015ca
...@@ -1797,6 +1797,17 @@ static void setup_modinfo(struct module *mod, Elf_Shdr *sechdrs, ...@@ -1797,6 +1797,17 @@ static void setup_modinfo(struct module *mod, Elf_Shdr *sechdrs,
} }
} }
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 #ifdef CONFIG_KALLSYMS
/* lookup symbol in given range of kernel_symbols */ /* lookup symbol in given range of kernel_symbols */
...@@ -2506,6 +2517,7 @@ static noinline struct module *load_module(void __user *umod, ...@@ -2506,6 +2517,7 @@ static noinline struct module *load_module(void __user *umod,
synchronize_sched(); synchronize_sched();
module_arch_cleanup(mod); module_arch_cleanup(mod);
cleanup: cleanup:
free_modinfo(mod);
kobject_del(&mod->mkobj.kobj); kobject_del(&mod->mkobj.kobj);
kobject_put(&mod->mkobj.kobj); kobject_put(&mod->mkobj.kobj);
free_unload: free_unload:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册