mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
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	[thread overview]
Message-ID: <1470322560-18333-2-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1470322560-18333-1-git-send-email-lcapitulino@redhat.com>

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 <lcapitulino@redhat.com>
---
 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

  reply	other threads:[~2016-08-04 15:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04 14:55 [PATCH 0/2] x86/x2apic: fix conversion to CPU hotplug state machine Luiz Capitulino
2016-08-04 14:55 ` Luiz Capitulino [this message]
2016-08-04 18:45   ` [PATCH 1/2] x86/x2apic: fix NULL pointer def during boot Davidlohr Bueso
2016-08-10  8:26   ` Igor Mammedov
2016-08-10  8:38   ` Igor Mammedov
2016-08-04 14:56 ` [PATCH 2/2] x86/x2apic: check return value on probe Luiz Capitulino
2016-08-09 13:28 ` [PATCH 0/2] x86/x2apic: fix conversion to CPU hotplug state machine Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470322560-18333-2-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=anna-maria@linutronix.de \
    --cc=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®