]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf branch: Avoid incrementing NULL
authorIan Rogers <irogers@google.com>
Thu, 12 Mar 2026 22:31:31 +0000 (15:31 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Fri, 13 Mar 2026 21:13:02 +0000 (14:13 -0700)
If the entry is NULL the value is meaningless so early return NULL to
avoid an increment of NULL. This was happening in calls from
has_stitched_lbr when running the "perf record LBR tests". The return
value isn't used in that case, so returning NULL as no effect.

Fixes: 42bbabed09ce ("perf tools: Add hw_idx in struct branch_stack")
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/branch.h

index 7429530fa7749096fb7f7277efe5cdd308d18d32..a1d4736497c407deba140f12f442f5b497a6cf11 100644 (file)
@@ -66,6 +66,9 @@ static inline struct branch_entry *perf_sample__branch_entries(struct perf_sampl
 {
        u64 *entry = (u64 *)sample->branch_stack;
 
+       if (entry == NULL)
+               return NULL;
+
        entry++;
        if (sample->no_hw_idx)
                return (struct branch_entry *)entry;