Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

module: initialize module dynamic debug later

We should initialize the module dynamic debug datastructures
only after determining that the module is not loaded yet. This
fixes a bug that introduced in 2.6.35-rc2, where when a trying
to load a module twice, we also load it's dynamic printing data
twice which causes all sorts of nasty issues. Also handle
the dynamic debug cleanup later on failure.

Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (removed a #ifdef)
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Yehuda Sadeh and committed by
Linus Torvalds
ff49d74a e3668dd8

+18 -11
+2 -2
include/linux/dynamic_debug.h
··· 40 40 const char *modname); 41 41 42 42 #if defined(CONFIG_DYNAMIC_DEBUG) 43 - extern int ddebug_remove_module(char *mod_name); 43 + extern int ddebug_remove_module(const char *mod_name); 44 44 45 45 #define __dynamic_dbg_enabled(dd) ({ \ 46 46 int __ret = 0; \ ··· 73 73 74 74 #else 75 75 76 - static inline int ddebug_remove_module(char *mod) 76 + static inline int ddebug_remove_module(const char *mod) 77 77 { 78 78 return 0; 79 79 }
+15 -8
kernel/module.c
··· 2062 2062 #endif 2063 2063 } 2064 2064 2065 + static void dynamic_debug_remove(struct _ddebug *debug) 2066 + { 2067 + if (debug) 2068 + ddebug_remove_module(debug->modname); 2069 + } 2070 + 2065 2071 static void *module_alloc_update_bounds(unsigned long size) 2066 2072 { 2067 2073 void *ret = module_alloc(size); ··· 2130 2124 void *ptr = NULL; /* Stops spurious gcc warning */ 2131 2125 unsigned long symoffs, stroffs, *strmap; 2132 2126 void __percpu *percpu; 2127 + struct _ddebug *debug = NULL; 2128 + unsigned int num_debug = 0; 2133 2129 2134 2130 mm_segment_t old_fs; 2135 2131 ··· 2484 2476 kfree(strmap); 2485 2477 strmap = NULL; 2486 2478 2487 - if (!mod->taints) { 2488 - struct _ddebug *debug; 2489 - unsigned int num_debug; 2490 - 2479 + if (!mod->taints) 2491 2480 debug = section_objs(hdr, sechdrs, secstrings, "__verbose", 2492 2481 sizeof(*debug), &num_debug); 2493 - if (debug) 2494 - dynamic_debug_setup(debug, num_debug); 2495 - } 2496 2482 2497 2483 err = module_finalize(hdr, sechdrs, mod); 2498 2484 if (err < 0) ··· 2528 2526 goto unlock; 2529 2527 } 2530 2528 2529 + if (debug) 2530 + dynamic_debug_setup(debug, num_debug); 2531 + 2531 2532 /* Find duplicate symbols */ 2532 2533 err = verify_export_symbols(mod); 2533 2534 if (err < 0) 2534 - goto unlock; 2535 + goto ddebug; 2535 2536 2536 2537 list_add_rcu(&mod->list, &modules); 2537 2538 mutex_unlock(&module_mutex); ··· 2562 2557 mutex_lock(&module_mutex); 2563 2558 /* Unlink carefully: kallsyms could be walking list. */ 2564 2559 list_del_rcu(&mod->list); 2560 + ddebug: 2561 + dynamic_debug_remove(debug); 2565 2562 unlock: 2566 2563 mutex_unlock(&module_mutex); 2567 2564 synchronize_sched();
+1 -1
lib/dynamic_debug.c
··· 692 692 * Called in response to a module being unloaded. Removes 693 693 * any ddebug_table's which point at the module. 694 694 */ 695 - int ddebug_remove_module(char *mod_name) 695 + int ddebug_remove_module(const char *mod_name) 696 696 { 697 697 struct ddebug_table *dt, *nextdt; 698 698 int ret = -ENOENT;