From: Anubhav Shelat Date: Wed, 1 Apr 2026 13:24:43 +0000 (-0400) Subject: perf tools: prevent null dsos from being added X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff6be45adb1989698867938157f9317ae0bba936;p=thirdparty%2Flinux.git perf tools: prevent null dsos from being added When sorting the dso array we sometimes get a crash due to null comparisons in comparator functions. So prevent __dsos__add from adding null to the dso array to avoid out-of-memory related errors. Signed-off-by: Anubhav Shelat Reviewed-by: Ian Rogers Signed-off-by: Namhyung Kim --- diff --git a/tools/perf/util/dsos.c b/tools/perf/util/dsos.c index 0a7645c7fae7d..5cf8c878bab2a 100644 --- a/tools/perf/util/dsos.c +++ b/tools/perf/util/dsos.c @@ -196,6 +196,9 @@ static struct dso *__dsos__find_by_longname_id(struct dsos *dsos, int __dsos__add(struct dsos *dsos, struct dso *dso) { + if (!dso) + return -EINVAL; + if (dsos->cnt == dsos->allocated) { unsigned int to_allocate = 2; struct dso **temp;