Commit cdf6d006 authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Linus Torvalds

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.dkSigned-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Acked-by: default avatarJason 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2bdde670
...@@ -847,17 +847,17 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, ...@@ -847,17 +847,17 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
const char *name) const char *name)
{ {
struct ddebug_table *dt; struct ddebug_table *dt;
const char *new_name;
dt = kzalloc(sizeof(*dt), GFP_KERNEL); dt = kzalloc(sizeof(*dt), GFP_KERNEL);
if (dt == NULL) if (dt == NULL)
return -ENOMEM; return -ENOMEM;
new_name = kstrdup_const(name, GFP_KERNEL); /*
if (new_name == NULL) { * For built-in modules, name lives in .rodata and is
kfree(dt); * immortal. For loaded modules, name points at the name[]
return -ENOMEM; * member of struct module, which lives at least as long as
} * this struct ddebug_table.
dt->mod_name = new_name; */
dt->mod_name = name;
dt->num_ddebugs = n; dt->num_ddebugs = n;
dt->ddebugs = tab; dt->ddebugs = tab;
...@@ -913,7 +913,6 @@ int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *module) ...@@ -913,7 +913,6 @@ int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *module)
static void ddebug_table_free(struct ddebug_table *dt) static void ddebug_table_free(struct ddebug_table *dt)
{ {
list_del_init(&dt->link); list_del_init(&dt->link);
kfree_const(dt->mod_name);
kfree(dt); kfree(dt);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment