aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/module.c')
-rw-r--r--kernel/module.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/kernel/module.c b/kernel/module.c
index f0e04d6b67d8..f77ac320d0b5 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -856,7 +856,7 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
856 mutex_lock(&module_mutex); 856 mutex_lock(&module_mutex);
857 /* Store the name of the last unloaded module for diagnostic purposes */ 857 /* Store the name of the last unloaded module for diagnostic purposes */
858 strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); 858 strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module));
859 unregister_dynamic_debug_module(mod->name); 859 ddebug_remove_module(mod->name);
860 free_module(mod); 860 free_module(mod);
861 861
862 out: 862 out:
@@ -1861,19 +1861,13 @@ static inline void add_kallsyms(struct module *mod,
1861} 1861}
1862#endif /* CONFIG_KALLSYMS */ 1862#endif /* CONFIG_KALLSYMS */
1863 1863
1864static void dynamic_printk_setup(struct mod_debug *debug, unsigned int num) 1864static void dynamic_debug_setup(struct _ddebug *debug, unsigned int num)
1865{ 1865{
1866#ifdef CONFIG_DYNAMIC_PRINTK_DEBUG 1866#ifdef CONFIG_DYNAMIC_DEBUG
1867 unsigned int i; 1867 if (ddebug_add_module(debug, num, debug->modname))
1868 1868 printk(KERN_ERR "dynamic debug error adding module: %s\n",
1869 for (i = 0; i < num; i++) { 1869 debug->modname);
1870 register_dynamic_debug_module(debug[i].modname, 1870#endif
1871 debug[i].type,
1872 debug[i].logical_modname,
1873 debug[i].flag_names,
1874 debug[i].hash, debug[i].hash2);
1875 }
1876#endif /* CONFIG_DYNAMIC_PRINTK_DEBUG */
1877} 1871}
1878 1872
1879static void *module_alloc_update_bounds(unsigned long size) 1873static void *module_alloc_update_bounds(unsigned long size)
@@ -2049,14 +2043,6 @@ static noinline struct module *load_module(void __user *umod,
2049 if (err < 0) 2043 if (err < 0)
2050 goto free_mod; 2044 goto free_mod;
2051 2045
2052#if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP)
2053 mod->refptr = percpu_modalloc(sizeof(local_t), __alignof__(local_t),
2054 mod->name);
2055 if (!mod->refptr) {
2056 err = -ENOMEM;
2057 goto free_mod;
2058 }
2059#endif
2060 if (pcpuindex) { 2046 if (pcpuindex) {
2061 /* We have a special allocation for this section. */ 2047 /* We have a special allocation for this section. */
2062 percpu = percpu_modalloc(sechdrs[pcpuindex].sh_size, 2048 percpu = percpu_modalloc(sechdrs[pcpuindex].sh_size,
@@ -2064,7 +2050,7 @@ static noinline struct module *load_module(void __user *umod,
2064 mod->name); 2050 mod->name);
2065 if (!percpu) { 2051 if (!percpu) {
2066 err = -ENOMEM; 2052 err = -ENOMEM;
2067 goto free_percpu; 2053 goto free_mod;
2068 } 2054 }
2069 sechdrs[pcpuindex].sh_flags &= ~(unsigned long)SHF_ALLOC; 2055 sechdrs[pcpuindex].sh_flags &= ~(unsigned long)SHF_ALLOC;
2070 mod->percpu = percpu; 2056 mod->percpu = percpu;
@@ -2116,6 +2102,14 @@ static noinline struct module *load_module(void __user *umod,
2116 /* Module has been moved. */ 2102 /* Module has been moved. */
2117 mod = (void *)sechdrs[modindex].sh_addr; 2103 mod = (void *)sechdrs[modindex].sh_addr;
2118 2104
2105#if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP)
2106 mod->refptr = percpu_modalloc(sizeof(local_t), __alignof__(local_t),
2107 mod->name);
2108 if (!mod->refptr) {
2109 err = -ENOMEM;
2110 goto free_init;
2111 }
2112#endif
2119 /* Now we've moved module, initialize linked lists, etc. */ 2113 /* Now we've moved module, initialize linked lists, etc. */
2120 module_unload_init(mod); 2114 module_unload_init(mod);
2121 2115
@@ -2247,12 +2241,13 @@ static noinline struct module *load_module(void __user *umod,
2247 add_kallsyms(mod, sechdrs, symindex, strindex, secstrings); 2241 add_kallsyms(mod, sechdrs, symindex, strindex, secstrings);
2248 2242
2249 if (!mod->taints) { 2243 if (!mod->taints) {
2250 struct mod_debug *debug; 2244 struct _ddebug *debug;
2251 unsigned int num_debug; 2245 unsigned int num_debug;
2252 2246
2253 debug = section_objs(hdr, sechdrs, secstrings, "__verbose", 2247 debug = section_objs(hdr, sechdrs, secstrings, "__verbose",
2254 sizeof(*debug), &num_debug); 2248 sizeof(*debug), &num_debug);
2255 dynamic_printk_setup(debug, num_debug); 2249 if (debug)
2250 dynamic_debug_setup(debug, num_debug);
2256 } 2251 }
2257 2252
2258 /* sechdrs[0].sh_size is always zero */ 2253 /* sechdrs[0].sh_size is always zero */
@@ -2322,15 +2317,17 @@ static noinline struct module *load_module(void __user *umod,
2322 ftrace_release(mod->module_core, mod->core_size); 2317 ftrace_release(mod->module_core, mod->core_size);
2323 free_unload: 2318 free_unload:
2324 module_unload_free(mod); 2319 module_unload_free(mod);
2320 free_init:
2321#if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP)
2322 percpu_modfree(mod->refptr);
2323#endif
2325 module_free(mod, mod->module_init); 2324 module_free(mod, mod->module_init);
2326 free_core: 2325 free_core:
2327 module_free(mod, mod->module_core); 2326 module_free(mod, mod->module_core);
2327 /* mod will be freed with core. Don't access it beyond this line! */
2328 free_percpu: 2328 free_percpu:
2329 if (percpu) 2329 if (percpu)
2330 percpu_modfree(percpu); 2330 percpu_modfree(percpu);
2331#if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP)
2332 percpu_modfree(mod->refptr);
2333#endif
2334 free_mod: 2331 free_mod:
2335 kfree(args); 2332 kfree(args);
2336 free_hdr: 2333 free_hdr: