提交 175d2aa0 编写于 作者: G Greg Kurz 提交者: David Gibson

spapr: sanitize error handling in spapr_ics_create()

The spapr_ics_create() function handles errors in a rather convoluted
way, with two local Error * variables. Moreover, failing to parent the
ICS object to the machine should be considered as a bug but it is
currently ignored.

This patch addresses both issues.
Signed-off-by: NGreg Kurz <groug@kaod.org>
Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
上级 f63ebfe0
...@@ -101,21 +101,26 @@ static ICSState *spapr_ics_create(sPAPRMachineState *spapr, ...@@ -101,21 +101,26 @@ static ICSState *spapr_ics_create(sPAPRMachineState *spapr,
const char *type_ics, const char *type_ics,
int nr_irqs, Error **errp) int nr_irqs, Error **errp)
{ {
Error *err = NULL, *local_err = NULL; Error *local_err = NULL;
Object *obj; Object *obj;
obj = object_new(type_ics); obj = object_new(type_ics);
object_property_add_child(OBJECT(spapr), "ics", obj, NULL); object_property_add_child(OBJECT(spapr), "ics", obj, &error_abort);
object_property_add_const_link(obj, "xics", OBJECT(spapr), &error_abort); object_property_add_const_link(obj, "xics", OBJECT(spapr), &error_abort);
object_property_set_int(obj, nr_irqs, "nr-irqs", &err); object_property_set_int(obj, nr_irqs, "nr-irqs", &local_err);
if (local_err) {
goto error;
}
object_property_set_bool(obj, true, "realized", &local_err); object_property_set_bool(obj, true, "realized", &local_err);
error_propagate(&err, local_err); if (local_err) {
if (err) { goto error;
error_propagate(errp, err);
return NULL;
} }
return ICS_SIMPLE(obj); return ICS_SIMPLE(obj);
error:
error_propagate(errp, local_err);
return NULL;
} }
static void xics_system_init(MachineState *machine, int nr_irqs, Error **errp) static void xics_system_init(MachineState *machine, int nr_irqs, Error **errp)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册