Skip to content

Commit 9878e6e

Browse files
captain5050gregkh
authored andcommitted
perf branch: Avoid incrementing NULL
[ Upstream commit c969a9d ] 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: 42bbabe ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 518ae2a commit 9878e6e

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

tools/perf/util/branch.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ static inline struct branch_entry *perf_sample__branch_entries(struct perf_sampl
6666
{
6767
u64 *entry = (u64 *)sample->branch_stack;
6868

69+
if (entry == NULL)
70+
return NULL;
71+
6972
entry++;
7073
if (sample->no_hw_idx)
7174
return (struct branch_entry *)entry;

0 commit comments

Comments
 (0)