From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754730AbcITOPl (ORCPT ); Tue, 20 Sep 2016 10:15:41 -0400 Received: from terminus.zytor.com ([198.137.202.10]:56650 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752777AbcITOPi (ORCPT ); Tue, 20 Sep 2016 10:15:38 -0400 Date: Tue, 20 Sep 2016 07:13:47 -0700 From: tip-bot for Sebastian Andrzej Siewior Message-ID: Cc: a.p.zijlstra@chello.nl, acme@infradead.org, bigeasy@linutronix.de, tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com, alexander.shishkin@linux.intel.com, mingo@kernel.org Reply-To: linux-kernel@vger.kernel.org, hpa@zytor.com, alexander.shishkin@linux.intel.com, a.p.zijlstra@chello.nl, acme@infradead.org, bigeasy@linutronix.de, tglx@linutronix.de, mingo@kernel.org In-Reply-To: <20160920131220.xg5pbdjtznszuyzb@breakpoint.cc> References: <20160920131220.xg5pbdjtznszuyzb@breakpoint.cc> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf/x86/intel/bts: Make sure debug store is valid Git-Commit-ID: f1e1c9e5e357c05253affb13be29285c5cb56bf0 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: f1e1c9e5e357c05253affb13be29285c5cb56bf0 Gitweb: http://git.kernel.org/tip/f1e1c9e5e357c05253affb13be29285c5cb56bf0 Author: Sebastian Andrzej Siewior AuthorDate: Tue, 20 Sep 2016 15:12:21 +0200 Committer: Thomas Gleixner CommitDate: Tue, 20 Sep 2016 16:06:09 +0200 perf/x86/intel/bts: Make sure debug store is valid Since commit 4d4c47412464 ("perf/x86/intel/bts: Fix BTS PMI detection") my box goes boom on boot: | .... node #0, CPUs: #1 #2 #3 #4 #5 #6 #7 | BUG: unable to handle kernel NULL pointer dereference at 0000000000000018 | IP: [] intel_bts_interrupt+0x43/0x130 | Call Trace: | d [] intel_pmu_handle_irq+0x51/0x4b0 | [] perf_event_nmi_handler+0x27/0x40 This happens because the code introduced in this commit dereferences the debug store pointer unconditionally. The debug store is not guaranteed to be available, so a NULL pointer check as on other places is required. Fixes: 4d4c47412464 ("perf/x86/intel/bts: Fix BTS PMI detection") Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Peter Zijlstra Cc: vince@deater.net Cc: eranian@google.com Link: http://lkml.kernel.org/r/20160920131220.xg5pbdjtznszuyzb@breakpoint.cc Signed-off-by: Thomas Gleixner --- arch/x86/events/intel/bts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c index bdcd651..6ff66ef 100644 --- a/arch/x86/events/intel/bts.c +++ b/arch/x86/events/intel/bts.c @@ -455,7 +455,7 @@ int intel_bts_interrupt(void) * The only surefire way of knowing if this NMI is ours is by checking * the write ptr against the PMI threshold. */ - if (ds->bts_index >= ds->bts_interrupt_threshold) + if (ds && (ds->bts_index >= ds->bts_interrupt_threshold)) handled = 1; /*