Skip to content

Commit a725bc9

Browse files
bibo-maoMarkus Armbruster
authored andcommitted
target/loongarch: Clean up virt_cpu_irq_init() error handling
The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call. virt_cpu_irq_init() is wrong that way: it passes &err to hotplug_handler_plug() twice. If both calls failed, this could trip error_setv()'s assertion. Moreover, if just one fails, the Error object leaks. Fortunately, these calls can't actually fail. Messed up in commit 50ebc3f (hw/intc/loongarch_ipi: Notify ipi object when cpu is plugged) and commit 087a23a (hw/intc/loongarch_extioi: Use cpu plug notification). Clean this up by passing &error_abort instead. Signed-off-by: Bibo Mao <[email protected]> Acked-by: Markus Armbruster <[email protected]> Message-ID: <[email protected]> Signed-off-by: Markus Armbruster <[email protected]>
1 parent daf78a9 commit a725bc9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

hw/loongarch/virt.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ static void virt_cpu_irq_init(LoongArchVirtMachineState *lvms)
327327
MachineClass *mc = MACHINE_GET_CLASS(ms);
328328
const CPUArchIdList *possible_cpus;
329329
CPUState *cs;
330-
Error *err = NULL;
331330

332331
/* cpu nodes */
333332
possible_cpus = mc->possible_cpu_arch_ids(ms);
@@ -337,8 +336,10 @@ static void virt_cpu_irq_init(LoongArchVirtMachineState *lvms)
337336
continue;
338337
}
339338

340-
hotplug_handler_plug(HOTPLUG_HANDLER(lvms->ipi), DEVICE(cs), &err);
341-
hotplug_handler_plug(HOTPLUG_HANDLER(lvms->extioi), DEVICE(cs), &err);
339+
hotplug_handler_plug(HOTPLUG_HANDLER(lvms->ipi), DEVICE(cs),
340+
&error_abort);
341+
hotplug_handler_plug(HOTPLUG_HANDLER(lvms->extioi), DEVICE(cs),
342+
&error_abort);
342343
}
343344
}
344345

0 commit comments

Comments
 (0)