Commit 07ade45a authored by Christophe Leroy's avatar Christophe Leroy Committed by Luis Chamberlain

module: Increase readability of module_kallsyms_lookup_name()

module_kallsyms_lookup_name() has several exit conditions but
can't return immediately due to preempt_disable().

Refactor module_kallsyms_lookup_name() to allow returning from
anywhere, and reduce depth.
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
parent ecc726f1
...@@ -457,29 +457,39 @@ unsigned long find_kallsyms_symbol_value(struct module *mod, const char *name) ...@@ -457,29 +457,39 @@ unsigned long find_kallsyms_symbol_value(struct module *mod, const char *name)
return 0; return 0;
} }
/* Look for this name: can be of form module:name. */ static unsigned long __module_kallsyms_lookup_name(const char *name)
unsigned long module_kallsyms_lookup_name(const char *name)
{ {
struct module *mod; struct module *mod;
char *colon; char *colon;
unsigned long ret = 0;
/* Don't lock: we're in enough trouble already. */
preempt_disable();
colon = strnchr(name, MODULE_NAME_LEN, ':'); colon = strnchr(name, MODULE_NAME_LEN, ':');
if (colon) { if (colon) {
mod = find_module_all(name, colon - name, false); mod = find_module_all(name, colon - name, false);
if (mod) if (mod)
ret = find_kallsyms_symbol_value(mod, colon + 1); return find_kallsyms_symbol_value(mod, colon + 1);
} else { return 0;
list_for_each_entry_rcu(mod, &modules, list) { }
if (mod->state == MODULE_STATE_UNFORMED)
continue; list_for_each_entry_rcu(mod, &modules, list) {
ret = find_kallsyms_symbol_value(mod, name); unsigned long ret;
if (ret)
break; if (mod->state == MODULE_STATE_UNFORMED)
} continue;
ret = find_kallsyms_symbol_value(mod, name);
if (ret)
return ret;
} }
return 0;
}
/* Look for this name: can be of form module:name. */
unsigned long module_kallsyms_lookup_name(const char *name)
{
unsigned long ret;
/* Don't lock: we're in enough trouble already. */
preempt_disable();
ret = __module_kallsyms_lookup_name(name);
preempt_enable(); preempt_enable();
return ret; return ret;
} }
......
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