[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240621170528.608772-4-namhyung@kernel.org>
Date: Fri, 21 Jun 2024 10:05:27 -0700
From: Namhyung Kim <namhyung@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Kan Liang <kan.liang@...ux.intel.com>
Cc: Jiri Olsa <jolsa@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
linux-perf-users@...r.kernel.org,
kernel test robot <oliver.sang@...el.com>
Subject: [PATCH 3/4] 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 <oliver.sang@...el.com>
Closes: https://lore.kernel.org/oe-lkp/202406180932.84be448c-oliver.sang@intel.com
Signed-off-by: Namhyung Kim <namhyung@...nel.org>
---
tools/perf/util/dsos.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/perf/util/dsos.c b/tools/perf/util/dsos.c
index ab3d0c01dd63..d5d78bdc56b2 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;
--
2.45.2.741.gdbec12cfda-goog
Powered by blists - more mailing lists