Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1456470

[PATCH 1/2] x86/x2apic: fix NULL pointer def during boot

From Luiz Capitulino <lcapitulino@redhat.com>
Newsgroups linux.kernel
Subject [PATCH 1/2] x86/x2apic: fix NULL pointer def during boot
Date 2016-08-04 17:10 +0200
Message-ID <s2srw-2sp-25@gated-at.bofh.it> (permalink)
References <s2srv-2sp-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] x86/x2apic: fix conversion to CPU hotplug state machine Luiz Capitulino <lcapitulino@redhat.com> - 2016-08-04 17:10 +0200
  [PATCH 1/2] x86/x2apic: fix NULL pointer def during boot Luiz Capitulino <lcapitulino@redhat.com> - 2016-08-04 17:10 +0200
    Re: [PATCH 1/2] x86/x2apic: fix NULL pointer def during boot Davidlohr Bueso <dave@stgolabs.net> - 2016-08-04 20:50 +0200
    [PATCH 1/2] x86/x2apic: fix NULL pointer def during boot Igor Mammedov <imammedo@redhat.com> - 2016-08-10 21:30 +0200
    [PATCH 1/2] x86/x2apic: fix NULL pointer def during boot Igor Mammedov <imammedo@redhat.com> - 2016-08-10 23:20 +0200
  [PATCH 2/2] x86/x2apic: check return value on probe Luiz Capitulino <lcapitulino@redhat.com> - 2016-08-04 17:10 +0200
  Re: [PATCH 0/2] x86/x2apic: fix conversion to CPU hotplug state  machine Luiz Capitulino <lcapitulino@redhat.com> - 2016-08-09 15:30 +0200

csiph-web