[PATCH] perf/x86: Fix NULL dereference in handle_pmi_common()

From: Tinu K Cheriya

Date: Fri Dec 12 2025 - 11:51:26 EST


syzbot reported a NULL pointer dereference in handle_pmi_common()
when the event pointer retrieved from cpuc->events[] is NULL but
is_pebs_counter_event_group() is called unconditionally.

Add a defensive NULL check before calling is_pebs_counter_event_group().

bug:220855

Signed-off-by: Tinu K Cheriya <tinuk11c@xxxxxxxxx>
---
arch/x86/events/intel/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 1e3ce060d..ee693946d 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3397,7 +3397,7 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
*
* The PEBS buffer has to be drained before handling the A-PMI
*/
- if(!event)
+ if (!event)
continue;
if (is_pebs_counter_event_group(event))
static_call(x86_pmu_drain_pebs)(regs, &data);
--
2.34.1