Skip to content

Commit

Permalink
kallsyms: Skip the name search for empty string
Browse files Browse the repository at this point in the history
When kallsyms_lookup_name is called with empty string,
it will do futile search for it through all the symbols.

Skipping the search for empty string.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220316122419.933957-3-jolsa@kernel.org
  • Loading branch information
Jiri Olsa authored and Alexei Starovoitov committed Mar 18, 2022
1 parent a0019cd commit aecf489
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/kallsyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ unsigned long kallsyms_lookup_name(const char *name)
unsigned long i;
unsigned int off;

/* Skip the search for empty string. */
if (!*name)
return 0;

for (i = 0, off = 0; i < kallsyms_num_syms; i++) {
off = kallsyms_expand_symbol(off, namebuf, ARRAY_SIZE(namebuf));

Expand Down

0 comments on commit aecf489

Please sign in to comment.