Skip to contentSkip to conversation

x86/microcode: Add missing unlock in microcode_update_helper()

PATCH In review Alejandro Vallejo 2 participants 2 messages Jun 5, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/microcode: Add missing unlock in microcode_update_helper()

microcode_update_helper() may return early while holding cpu_add_remove_lock, hence preventing any writers from taking it again.

Leave through the put label instead so it's properly released.

---
 xen/arch/x86/cpu/microcode/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/x86/cpu/microcode/core.c +2 -1
index c1033f3bc2..e65af4b82e 100644
@@ -599,7 +599,8 @@ static long cf_check microcode_update_helper(void *data)
         printk(XENLOG_WARNING
                "CPU%u is expected to lead ucode loading (but got CPU%u)\n",
                nmi_cpu, cpumask_first(&cpu_online_map));
-        return -EPERM;
+        ret = -EPERM;
+        goto put;
     }
 
     patch = parse_blob(buffer->buffer, buffer->len);
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Alejandro Vallejo

microcode_update_helper() may return early while holding cpu_add_remove_lock, hence preventing any writers from taking it again.

Leave through the put label instead so it's properly released.

Fixes 5ed12565aa32 ("microcode: rendezvous CPUs in NMI handler and load

ucode")

Quoted 1 line

I'll add the fixes on commit.

~Andrew