diff options
Diffstat (limited to 'kernel/module.c')
| -rw-r--r-- | kernel/module.c | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/kernel/module.c b/kernel/module.c index ba22484a987e..77672233387f 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
| @@ -822,7 +822,7 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user, | |||
| 822 | mutex_lock(&module_mutex); | 822 | mutex_lock(&module_mutex); |
| 823 | /* Store the name of the last unloaded module for diagnostic purposes */ | 823 | /* Store the name of the last unloaded module for diagnostic purposes */ |
| 824 | strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); | 824 | strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); |
| 825 | unregister_dynamic_debug_module(mod->name); | 825 | ddebug_remove_module(mod->name); |
| 826 | free_module(mod); | 826 | free_module(mod); |
| 827 | 827 | ||
| 828 | out: | 828 | out: |
| @@ -1827,19 +1827,13 @@ static inline void add_kallsyms(struct module *mod, | |||
| 1827 | } | 1827 | } |
| 1828 | #endif /* CONFIG_KALLSYMS */ | 1828 | #endif /* CONFIG_KALLSYMS */ |
| 1829 | 1829 | ||
| 1830 | static void dynamic_printk_setup(struct mod_debug *debug, unsigned int num) | 1830 | static void dynamic_debug_setup(struct _ddebug *debug, unsigned int num) |
| 1831 | { | 1831 | { |
| 1832 | #ifdef CONFIG_DYNAMIC_PRINTK_DEBUG | 1832 | #ifdef CONFIG_DYNAMIC_DEBUG |
| 1833 | unsigned int i; | 1833 | if (ddebug_add_module(debug, num, debug->modname)) |
| 1834 | 1834 | printk(KERN_ERR "dynamic debug error adding module: %s\n", | |
| 1835 | for (i = 0; i < num; i++) { | 1835 | debug->modname); |
| 1836 | register_dynamic_debug_module(debug[i].modname, | 1836 | #endif |
| 1837 | debug[i].type, | ||
| 1838 | debug[i].logical_modname, | ||
| 1839 | debug[i].flag_names, | ||
| 1840 | debug[i].hash, debug[i].hash2); | ||
| 1841 | } | ||
| 1842 | #endif /* CONFIG_DYNAMIC_PRINTK_DEBUG */ | ||
| 1843 | } | 1837 | } |
| 1844 | 1838 | ||
| 1845 | static void *module_alloc_update_bounds(unsigned long size) | 1839 | static void *module_alloc_update_bounds(unsigned long size) |
| @@ -2015,14 +2009,6 @@ static noinline struct module *load_module(void __user *umod, | |||
| 2015 | if (err < 0) | 2009 | if (err < 0) |
| 2016 | goto free_mod; | 2010 | goto free_mod; |
| 2017 | 2011 | ||
| 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) { | 2012 | if (pcpuindex) { |
| 2027 | /* We have a special allocation for this section. */ | 2013 | /* We have a special allocation for this section. */ |
| 2028 | percpu = percpu_modalloc(sechdrs[pcpuindex].sh_size, | 2014 | percpu = percpu_modalloc(sechdrs[pcpuindex].sh_size, |
| @@ -2030,7 +2016,7 @@ static noinline struct module *load_module(void __user *umod, | |||
| 2030 | mod->name); | 2016 | mod->name); |
| 2031 | if (!percpu) { | 2017 | if (!percpu) { |
| 2032 | err = -ENOMEM; | 2018 | err = -ENOMEM; |
| 2033 | goto free_percpu; | 2019 | goto free_mod; |
| 2034 | } | 2020 | } |
| 2035 | sechdrs[pcpuindex].sh_flags &= ~(unsigned long)SHF_ALLOC; | 2021 | sechdrs[pcpuindex].sh_flags &= ~(unsigned long)SHF_ALLOC; |
| 2036 | mod->percpu = percpu; | 2022 | mod->percpu = percpu; |
| @@ -2082,6 +2068,14 @@ static noinline struct module *load_module(void __user *umod, | |||
| 2082 | /* Module has been moved. */ | 2068 | /* Module has been moved. */ |
| 2083 | mod = (void *)sechdrs[modindex].sh_addr; | 2069 | mod = (void *)sechdrs[modindex].sh_addr; |
| 2084 | 2070 | ||
| 2071 | #if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP) | ||
| 2072 | mod->refptr = percpu_modalloc(sizeof(local_t), __alignof__(local_t), | ||
| 2073 | mod->name); | ||
| 2074 | if (!mod->refptr) { | ||
| 2075 | err = -ENOMEM; | ||
| 2076 | goto free_init; | ||
| 2077 | } | ||
| 2078 | #endif | ||
| 2085 | /* Now we've moved module, initialize linked lists, etc. */ | 2079 | /* Now we've moved module, initialize linked lists, etc. */ |
| 2086 | module_unload_init(mod); | 2080 | module_unload_init(mod); |
| 2087 | 2081 | ||
| @@ -2213,12 +2207,13 @@ static noinline struct module *load_module(void __user *umod, | |||
| 2213 | add_kallsyms(mod, sechdrs, symindex, strindex, secstrings); | 2207 | add_kallsyms(mod, sechdrs, symindex, strindex, secstrings); |
| 2214 | 2208 | ||
| 2215 | if (!mod->taints) { | 2209 | if (!mod->taints) { |
| 2216 | struct mod_debug *debug; | 2210 | struct _ddebug *debug; |
| 2217 | unsigned int num_debug; | 2211 | unsigned int num_debug; |
| 2218 | 2212 | ||
| 2219 | debug = section_objs(hdr, sechdrs, secstrings, "__verbose", | 2213 | debug = section_objs(hdr, sechdrs, secstrings, "__verbose", |
| 2220 | sizeof(*debug), &num_debug); | 2214 | sizeof(*debug), &num_debug); |
| 2221 | dynamic_printk_setup(debug, num_debug); | 2215 | if (debug) |
| 2216 | dynamic_debug_setup(debug, num_debug); | ||
| 2222 | } | 2217 | } |
| 2223 | 2218 | ||
| 2224 | /* sechdrs[0].sh_size is always zero */ | 2219 | /* sechdrs[0].sh_size is always zero */ |
| @@ -2288,15 +2283,17 @@ static noinline struct module *load_module(void __user *umod, | |||
| 2288 | ftrace_release(mod->module_core, mod->core_size); | 2283 | ftrace_release(mod->module_core, mod->core_size); |
| 2289 | free_unload: | 2284 | free_unload: |
| 2290 | module_unload_free(mod); | 2285 | module_unload_free(mod); |
| 2286 | free_init: | ||
| 2287 | #if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP) | ||
| 2288 | percpu_modfree(mod->refptr); | ||
| 2289 | #endif | ||
| 2291 | module_free(mod, mod->module_init); | 2290 | module_free(mod, mod->module_init); |
| 2292 | free_core: | 2291 | free_core: |
| 2293 | module_free(mod, mod->module_core); | 2292 | module_free(mod, mod->module_core); |
| 2293 | /* mod will be freed with core. Don't access it beyond this line! */ | ||
| 2294 | free_percpu: | 2294 | free_percpu: |
| 2295 | if (percpu) | 2295 | if (percpu) |
| 2296 | percpu_modfree(percpu); | 2296 | percpu_modfree(percpu); |
| 2297 | #if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP) | ||
| 2298 | percpu_modfree(mod->refptr); | ||
| 2299 | #endif | ||
| 2300 | free_mod: | 2297 | free_mod: |
| 2301 | kfree(args); | 2298 | kfree(args); |
| 2302 | free_hdr: | 2299 | free_hdr: |
