aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamhyung Kim <[email protected]>2024-06-21 10:05:27 -0700
committerNamhyung Kim <[email protected]>2024-06-25 11:06:20 -0700
commit0eb739d87f1b4780af0168e479d87627a33b6e3d (patch)
tree30f54be0a1b6dff33ed6bba906a0577f315088b3
parente988a5b53ebd40c2fafc86250e95d69929796fbd (diff)
perf tools: Fix a compiler warning of NULL pointer
A compiler warning on the second argument of bsearch() should not be NULL, but there's a case we might pass it. Let's return early if we don't have any DSOs to search in __dsos__find_by_longname_id(). util/dsos.c:184:8: runtime error: null pointer passed as argument 2, which is declared to never be null Reported-by: kernel test robot <[email protected]> Reviewed-by: Kan Liang <[email protected]> Closes: https://lore.kernel.org/oe-lkp/[email protected] Signed-off-by: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected]
-rw-r--r--tools/perf/util/dsos.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/perf/util/dsos.c b/tools/perf/util/dsos.c
index 846828ea1f00..5e5e05f86dd3 100644
--- a/tools/perf/util/dsos.c
+++ b/tools/perf/util/dsos.c
@@ -164,6 +164,9 @@ static struct dso *__dsos__find_by_longname_id(struct dsos *dsos,
};
struct dso **res;
+ if (dsos->dsos == NULL)
+ return NULL;
+
if (!dsos->sorted) {
if (!write_locked) {
struct dso *dso;