From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964944AbcHDPGr (ORCPT ); Thu, 4 Aug 2016 11:06:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44070 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758713AbcHDPGo (ORCPT ); Thu, 4 Aug 2016 11:06:44 -0400 From: Luiz Capitulino To: linux-kernel@vger.kernel.org Cc: bigeasy@linutronix.de, tglx@linutronix.de, anna-maria@linutronix.de Subject: [PATCH 1/2] x86/x2apic: fix NULL pointer def during boot Date: Thu, 4 Aug 2016 10:55:59 -0400 Message-Id: <1470322560-18333-2-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1470322560-18333-1-git-send-email-lcapitulino@redhat.com> References: <1470322560-18333-1-git-send-email-lcapitulino@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 04 Aug 2016 14:56:09 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 6b2c28471, moved the allocation of cpus_in_cluster to the x2apic_prepare_cpu() callback. However, it forgot to move the cpumask_set_cpu() call that uses it. This generates a NULL pointer dereference during boot in machines with x2apic_mode=true. Signed-off-by: Luiz Capitulino --- arch/x86/kernel/apic/x2apic_cluster.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c index 6368fa6..18b1704 100644 --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -165,6 +165,8 @@ int x2apic_prepare_cpu(unsigned int cpu) return -ENOMEM; } + cpumask_set_cpu(cpu, per_cpu(cpus_in_cluster, cpu)); + return 0; } @@ -185,12 +187,9 @@ int x2apic_dead_cpu(unsigned int this_cpu) static int x2apic_cluster_probe(void) { - int cpu = smp_processor_id(); - 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); return 1; -- 2.5.5