From: Borislav Petkov <b...@suse.de>

We do get_online_cpus() and then start noodling with the bits. Do that
*before* we grab the hotplug lock. This accidentally fixes the other
issue where we check if a CPU is online but then go ahead and find out
the NBC core which might not be the same CPU as the CPU we want to
inject on.

Signed-off-by: Borislav Petkov <b...@suse.de>
---
 drivers/edac/mce_amd_inj.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/edac/mce_amd_inj.c b/drivers/edac/mce_amd_inj.c
index 30227f30e7c6..5001d166f54f 100644
--- a/drivers/edac/mce_amd_inj.c
+++ b/drivers/edac/mce_amd_inj.c
@@ -266,10 +266,6 @@ static void do_inject(void)
                i_mce.status &= ~MCI_STATUS_UC;
        }
 
-       get_online_cpus();
-       if (!cpu_online(cpu))
-               goto err;
-
        /* prep MCE global settings for the injection */
        mcg_status = MCG_STATUS_MCIP | MCG_STATUS_EIPV;
 
@@ -290,6 +286,10 @@ static void do_inject(void)
                cpu = get_nbc_for_node(amd_get_nb_id(cpu));
        }
 
+       get_online_cpus();
+       if (!cpu_online(cpu))
+               goto err;
+
        toggle_hw_mce_inject(cpu, true);
 
        wrmsr_on_cpu(cpu, MSR_IA32_MCG_STATUS,
-- 
2.3.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to