Commit 4573fe15 authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Linus Torvalds

dynamic_debug: use pointer comparison in ddebug_remove_module

Now that we store the passed-in string directly in ddebug_add_module, we
can use pointer equality instead of strcmp.  This is a little more
efficient, but more importantly, this also makes the code somewhat more
correct:

Currently, if one loads and then unloads a module whose name happens to
match the KBUILD_MODNAME of some built-in functionality (which need not
even be modular at all), all of their dynamic debug entries vanish along
with those of the actual module.  For example, loading and unloading a
core.ko hides all pr_debugs from drivers/base/core.c and other built-in
files called core.c (incidentally, there is an in-tree module whose name
is core, but I just tested this with an out-of-tree trivial one).

Link: http://lkml.kernel.org/r/20190212214150.4807-7-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 cdf6d006
...@@ -929,9 +929,10 @@ int ddebug_remove_module(const char *mod_name) ...@@ -929,9 +929,10 @@ int ddebug_remove_module(const char *mod_name)
mutex_lock(&ddebug_lock); mutex_lock(&ddebug_lock);
list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) { list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) {
if (!strcmp(dt->mod_name, mod_name)) { if (dt->mod_name == mod_name) {
ddebug_table_free(dt); ddebug_table_free(dt);
ret = 0; ret = 0;
break;
} }
} }
mutex_unlock(&ddebug_lock); mutex_unlock(&ddebug_lock);
......
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