Skip to content

Commit 5a71159

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 41d204e commit 5a71159

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
@@ -65,6 +65,9 @@ static inline struct branch_entry *perf_sample__branch_entries(struct perf_sampl
6565
{
6666
u64 *entry = (u64 *)sample->branch_stack;
6767

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

0 commit comments

Comments
 (0)