]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf tools: prevent null dsos from being added
authorAnubhav Shelat <ashelat@redhat.com>
Wed, 1 Apr 2026 13:24:43 +0000 (09:24 -0400)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 2 Apr 2026 19:51:10 +0000 (12:51 -0700)
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 <ashelat@redhat.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/dsos.c

index 0a7645c7fae7d3151fb8d4f60231ccb0be74fe1d..5cf8c878bab2a4a48a2a91707c7839493be4f43a 100644 (file)
@@ -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;