Commit 0eb739d8 authored by Namhyung Kim's avatar Namhyung Kim
Browse files

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: default avatarkernel test robot <oliver.sang@intel.com>
Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
Closes: https://lore.kernel.org/oe-lkp/202406180932.84be448c-oliver.sang@intel.com


Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240621170528.608772-4-namhyung@kernel.org
parent e988a5b5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;