diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-18 12:04:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-18 12:04:25 -0400 |
commit | 8144737def6abc49457124424887436531bd6a50 (patch) | |
tree | ac41fa015dc996a72420e7321bd52359bf10fedb | |
parent | 99dbe10968b495c14badbd50aee59a7f0459c8e6 (diff) | |
parent | 6e2b75740bed35df98b8113300579e13ed2ce848 (diff) |
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
-rw-r--r-- | kernel/module.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/kernel/module.c b/kernel/module.c index ba22484a987e..1196f5d11700 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -2015,14 +2015,6 @@ static noinline struct module *load_module(void __user *umod, | |||
2015 | if (err < 0) | 2015 | if (err < 0) |
2016 | goto free_mod; | 2016 | goto free_mod; |
2017 | 2017 | ||
2018 | #if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP) | ||
2019 | mod->refptr = percpu_modalloc(sizeof(local_t), __alignof__(local_t), | ||
2020 | mod->name); | ||
2021 | if (!mod->refptr) { | ||
2022 | err = -ENOMEM; | ||
2023 | goto free_mod; | ||
2024 | } | ||
2025 | #endif | ||
2026 | if (pcpuindex) { | 2018 | if (pcpuindex) { |
2027 | /* We have a special allocation for this section. */ | 2019 | /* We have a special allocation for this section. */ |
2028 | percpu = percpu_modalloc(sechdrs[pcpuindex].sh_size, | 2020 | percpu = percpu_modalloc(sechdrs[pcpuindex].sh_size, |
@@ -2030,7 +2022,7 @@ static noinline struct module *load_module(void __user *umod, | |||
2030 | mod->name); | 2022 | mod->name); |
2031 | if (!percpu) { | 2023 | if (!percpu) { |
2032 | err = -ENOMEM; | 2024 | err = -ENOMEM; |
2033 | goto free_percpu; | 2025 | goto free_mod; |
2034 | } | 2026 | } |
2035 | sechdrs[pcpuindex].sh_flags &= ~(unsigned long)SHF_ALLOC; | 2027 | sechdrs[pcpuindex].sh_flags &= ~(unsigned long)SHF_ALLOC; |
2036 | mod->percpu = percpu; | 2028 | mod->percpu = percpu; |
@@ -2082,6 +2074,14 @@ static noinline struct module *load_module(void __user *umod, | |||
2082 | /* Module has been moved. */ | 2074 | /* Module has been moved. */ |
2083 | mod = (void *)sechdrs[modindex].sh_addr; | 2075 | mod = (void *)sechdrs[modindex].sh_addr; |
2084 | 2076 | ||
2077 | #if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP) | ||
2078 | mod->refptr = percpu_modalloc(sizeof(local_t), __alignof__(local_t), | ||
2079 | mod->name); | ||
2080 | if (!mod->refptr) { | ||
2081 | err = -ENOMEM; | ||
2082 | goto free_init; | ||
2083 | } | ||
2084 | #endif | ||
2085 | /* Now we've moved module, initialize linked lists, etc. */ | 2085 | /* Now we've moved module, initialize linked lists, etc. */ |
2086 | module_unload_init(mod); | 2086 | module_unload_init(mod); |
2087 | 2087 | ||
@@ -2288,15 +2288,17 @@ static noinline struct module *load_module(void __user *umod, | |||
2288 | ftrace_release(mod->module_core, mod->core_size); | 2288 | ftrace_release(mod->module_core, mod->core_size); |
2289 | free_unload: | 2289 | free_unload: |
2290 | module_unload_free(mod); | 2290 | module_unload_free(mod); |
2291 | free_init: | ||
2292 | #if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP) | ||
2293 | percpu_modfree(mod->refptr); | ||
2294 | #endif | ||
2291 | module_free(mod, mod->module_init); | 2295 | module_free(mod, mod->module_init); |
2292 | free_core: | 2296 | free_core: |
2293 | module_free(mod, mod->module_core); | 2297 | module_free(mod, mod->module_core); |
2298 | /* mod will be freed with core. Don't access it beyond this line! */ | ||
2294 | free_percpu: | 2299 | free_percpu: |
2295 | if (percpu) | 2300 | if (percpu) |
2296 | percpu_modfree(percpu); | 2301 | percpu_modfree(percpu); |
2297 | #if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP) | ||
2298 | percpu_modfree(mod->refptr); | ||
2299 | #endif | ||
2300 | free_mod: | 2302 | free_mod: |
2301 | kfree(args); | 2303 | kfree(args); |
2302 | free_hdr: | 2304 | free_hdr: |