From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751982AbcHLFbX (ORCPT ); Fri, 12 Aug 2016 01:31:23 -0400 Received: from mga09.intel.com ([134.134.136.24]:5535 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750878AbcHLFbV (ORCPT ); Fri, 12 Aug 2016 01:31:21 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,508,1464678000"; d="scan'208";a="154631600" From: Huaitong Han To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Huaitong Han Subject: [PATCH] x86/x2apic: fix x2apic_cluster_probe null pointer Date: Fri, 12 Aug 2016 13:30:56 +0800 Message-Id: <1470979856-12290-1-git-send-email-huaitong.han@intel.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org percpu cpus_in_cluster is a pointer with CONFIG_CPUMASK_OFFSTACK, cpu_in_cluster is not alloced memory before x2apic_prepare_cpu is invoked, so cpumask_set_cpu would get a NULL pointer bug: BUG: unable to handle kernel NULL pointer dereference at (null) IP: [] x2apic_cluster_probe+0x35/0x70 Signed-off-by: Huaitong Han --- arch/x86/kernel/apic/x2apic_cluster.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c index 6368fa6..6acb055 100644 --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -190,9 +190,10 @@ static int x2apic_cluster_probe(void) if (!x2apic_mode) return 0; - cpumask_set_cpu(cpu, per_cpu(cpus_in_cluster, cpu)); cpuhp_setup_state(CPUHP_X2APIC_PREPARE, "X2APIC_PREPARE", x2apic_prepare_cpu, x2apic_dead_cpu); + cpumask_set_cpu(cpu, per_cpu(cpus_in_cluster, cpu)); + return 1; } -- 1.8.3.1