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

Tinu K Cheriya posted 1 patch 1 day, 9 hours ago
arch/x86/events/intel/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] perf/x86: Fix NULL dereference in handle_pmi_common()
Posted by Tinu K Cheriya 1 day, 9 hours ago
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@gmail.com>
---
 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