diff options
author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2019-03-07 19:27:37 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-03-07 21:32:00 -0500 |
commit | cdf6d00696865ae1c46750059fd7d248323712f9 (patch) | |
tree | 08903df02a81ec1a5f20442842b7a68d1c3d7cb6 /lib/dynamic_debug.c | |
parent | 2bdde670beedf73de38b8607f0b1913358af7381 (diff) |
dynamic_debug: don't duplicate modname in ddebug_add_module
For built-in modules, we're already reusing the passed-in string via
kstrdup_const(). But for actual modules (i.e. when we're called from
dynamic_debug_setup in module.c), the passed-in string (which points at
the name[] array inside struct module) is also guaranteed to live at
least as long as the struct ddebug_table, since free_module() calls
ddebug_remove_module().
Link: http://lkml.kernel.org/r/20190212214150.4807-6-linux@rasmusvillemoes.dk
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Acked-by: Jason Baron <jbaron@akamai.com>
Cc: David Sterba <dsterba@suse.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Petr Mladek <pmladek@suse.com>
Cc: "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/dynamic_debug.c')
-rw-r--r-- | lib/dynamic_debug.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index dbf2b457e47e..8274c4ea75e0 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
@@ -847,17 +847,17 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, | |||
847 | const char *name) | 847 | const char *name) |
848 | { | 848 | { |
849 | struct ddebug_table *dt; | 849 | struct ddebug_table *dt; |
850 | const char *new_name; | ||
851 | 850 | ||
852 | dt = kzalloc(sizeof(*dt), GFP_KERNEL); | 851 | dt = kzalloc(sizeof(*dt), GFP_KERNEL); |
853 | if (dt == NULL) | 852 | if (dt == NULL) |
854 | return -ENOMEM; | 853 | return -ENOMEM; |
855 | new_name = kstrdup_const(name, GFP_KERNEL); | 854 | /* |
856 | if (new_name == NULL) { | 855 | * For built-in modules, name lives in .rodata and is |
857 | kfree(dt); | 856 | * immortal. For loaded modules, name points at the name[] |
858 | return -ENOMEM; | 857 | * member of struct module, which lives at least as long as |
859 | } | 858 | * this struct ddebug_table. |
860 | dt->mod_name = new_name; | 859 | */ |
860 | dt->mod_name = name; | ||
861 | dt->num_ddebugs = n; | 861 | dt->num_ddebugs = n; |
862 | dt->ddebugs = tab; | 862 | dt->ddebugs = tab; |
863 | 863 | ||
@@ -913,7 +913,6 @@ int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *module) | |||
913 | static void ddebug_table_free(struct ddebug_table *dt) | 913 | static void ddebug_table_free(struct ddebug_table *dt) |
914 | { | 914 | { |
915 | list_del_init(&dt->link); | 915 | list_del_init(&dt->link); |
916 | kfree_const(dt->mod_name); | ||
917 | kfree(dt); | 916 | kfree(dt); |
918 | } | 917 | } |
919 | 918 | ||