Skip to content

Commit 988ad4c

Browse files
bibo-maogaosong-loongson
authored andcommitted
hw/loongarch/virt: Fix cpuslot::cpu set at last in virt_cpu_plug()
In function virt_cpu_plug(), Object cpuslot::cpu is set at last only when there is no any error, otherwise it is problematic that cpuslot::cpu is set in advance however it returns because of error. Fixes: ab9935d (hw/loongarch/virt: Implement cpu plug interface) Signed-off-by: Bibo Mao <[email protected]> Reviewed-by: Markus Armbruster <[email protected]> Message-Id: <[email protected]> Signed-off-by: Song Gao <[email protected]>
1 parent dfaecc0 commit 988ad4c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

hw/loongarch/virt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,6 @@ static void virt_cpu_plug(HotplugHandler *hotplug_dev,
973973
LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(hotplug_dev);
974974
Error *err = NULL;
975975

976-
cpu_slot = virt_find_cpu_slot(MACHINE(lvms), cpu->phy_id);
977-
cpu_slot->cpu = CPU(dev);
978976
if (lvms->ipi) {
979977
hotplug_handler_plug(HOTPLUG_HANDLER(lvms->ipi), dev, &err);
980978
if (err) {
@@ -998,6 +996,8 @@ static void virt_cpu_plug(HotplugHandler *hotplug_dev,
998996
}
999997
}
1000998

999+
cpu_slot = virt_find_cpu_slot(MACHINE(lvms), cpu->phy_id);
1000+
cpu_slot->cpu = CPU(dev);
10011001
return;
10021002
}
10031003

0 commit comments

Comments
 (0)