Skip to content

Commit 117ceeb

Browse files
Stephane EranianPeter Zijlstra
authored andcommitted
perf/x86/utils: Fix uninitialized var in get_branch_type()
offset is passed as a pointer and on certain call path is not set by the function. If the caller does not re-initialize offset between calls, value could be inherited between calls. Prevent this by initializing offset on each call. This impacts the code in amd_pmu_lbr_filter() which does: for(i=0; ...) { ret = get_branch_type_fused(..., &offset); if (offset) lbr_entries[i].from += offset; } Fixes: df3e961 ("perf/x86: Make branch classifier fusion-aware") Signed-off-by: Stephane Eranian <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Sandipan Das <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent cfef80b commit 117ceeb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/x86/events/utils.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ static int get_branch_type(unsigned long from, unsigned long to, int abort,
9494
u8 buf[MAX_INSN_SIZE];
9595
int is64 = 0;
9696

97+
/* make sure we initialize offset */
98+
if (offset)
99+
*offset = 0;
100+
97101
to_plm = kernel_ip(to) ? X86_BR_KERNEL : X86_BR_USER;
98102
from_plm = kernel_ip(from) ? X86_BR_KERNEL : X86_BR_USER;
99103

0 commit comments

Comments
 (0)