perf symbol: Fix uninitialized return value in symbols__find_by_name()
authorJames Clark <james.clark@arm.com>
Fri, 30 Jun 2023 15:38:39 +0000 (16:38 +0100)
committerNamhyung Kim <namhyung@kernel.org>
Sat, 1 Jul 2023 17:49:13 +0000 (10:49 -0700)
commit78a175c4623f66722709494295a0f6754b46f858
treea867be0436cab85e9c20f951690dda2013f91b73
parent2aefb4cc904f17aad03acc3e05f44cef7801c497
perf symbol: Fix uninitialized return value in symbols__find_by_name()

found_idx and s aren't initialized, so if no symbol is found then the
assert at the end will index off the end of the array causing a
segfault. The function also doesn't return NULL when the symbol isn't
found even if the assert passes. Fix it by initializing the values and
only setting them when something is found.

Fixes the following test failure:

  $ perf test 1
  1: vmlinux symtab matches kallsyms     : FAILED!

Fixes: 259dce914e93 ("perf symbol: Remove symbol_name_rb_node")
Signed-off-by: James Clark <james.clark@arm.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Link: https://lore.kernel.org/r/20230630153840.858668-1-james.clark@arm.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/symbol.c