mirror of https://gitee.com/openkylin/linux.git
Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus: module: fix refptr allocation and release order
This commit is contained in:
commit
8144737def
|
@ -2015,14 +2015,6 @@ static noinline struct module *load_module(void __user *umod,
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto free_mod;
|
goto free_mod;
|
||||||
|
|
||||||
#if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP)
|
|
||||||
mod->refptr = percpu_modalloc(sizeof(local_t), __alignof__(local_t),
|
|
||||||
mod->name);
|
|
||||||
if (!mod->refptr) {
|
|
||||||
err = -ENOMEM;
|
|
||||||
goto free_mod;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (pcpuindex) {
|
if (pcpuindex) {
|
||||||
/* We have a special allocation for this section. */
|
/* We have a special allocation for this section. */
|
||||||
percpu = percpu_modalloc(sechdrs[pcpuindex].sh_size,
|
percpu = percpu_modalloc(sechdrs[pcpuindex].sh_size,
|
||||||
|
@ -2030,7 +2022,7 @@ static noinline struct module *load_module(void __user *umod,
|
||||||
mod->name);
|
mod->name);
|
||||||
if (!percpu) {
|
if (!percpu) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto free_percpu;
|
goto free_mod;
|
||||||
}
|
}
|
||||||
sechdrs[pcpuindex].sh_flags &= ~(unsigned long)SHF_ALLOC;
|
sechdrs[pcpuindex].sh_flags &= ~(unsigned long)SHF_ALLOC;
|
||||||
mod->percpu = percpu;
|
mod->percpu = percpu;
|
||||||
|
@ -2082,6 +2074,14 @@ static noinline struct module *load_module(void __user *umod,
|
||||||
/* Module has been moved. */
|
/* Module has been moved. */
|
||||||
mod = (void *)sechdrs[modindex].sh_addr;
|
mod = (void *)sechdrs[modindex].sh_addr;
|
||||||
|
|
||||||
|
#if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP)
|
||||||
|
mod->refptr = percpu_modalloc(sizeof(local_t), __alignof__(local_t),
|
||||||
|
mod->name);
|
||||||
|
if (!mod->refptr) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto free_init;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/* Now we've moved module, initialize linked lists, etc. */
|
/* Now we've moved module, initialize linked lists, etc. */
|
||||||
module_unload_init(mod);
|
module_unload_init(mod);
|
||||||
|
|
||||||
|
@ -2288,15 +2288,17 @@ static noinline struct module *load_module(void __user *umod,
|
||||||
ftrace_release(mod->module_core, mod->core_size);
|
ftrace_release(mod->module_core, mod->core_size);
|
||||||
free_unload:
|
free_unload:
|
||||||
module_unload_free(mod);
|
module_unload_free(mod);
|
||||||
module_free(mod, mod->module_init);
|
free_init:
|
||||||
free_core:
|
|
||||||
module_free(mod, mod->module_core);
|
|
||||||
free_percpu:
|
|
||||||
if (percpu)
|
|
||||||
percpu_modfree(percpu);
|
|
||||||
#if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP)
|
#if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP)
|
||||||
percpu_modfree(mod->refptr);
|
percpu_modfree(mod->refptr);
|
||||||
#endif
|
#endif
|
||||||
|
module_free(mod, mod->module_init);
|
||||||
|
free_core:
|
||||||
|
module_free(mod, mod->module_core);
|
||||||
|
/* mod will be freed with core. Don't access it beyond this line! */
|
||||||
|
free_percpu:
|
||||||
|
if (percpu)
|
||||||
|
percpu_modfree(percpu);
|
||||||
free_mod:
|
free_mod:
|
||||||
kfree(args);
|
kfree(args);
|
||||||
free_hdr:
|
free_hdr:
|
||||||
|
|
Loading…
Reference in New Issue