hw/xen: Fix xen_bus_realize() 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.

xen_bus_realize() is wrong that way: it passes &local_err to
xs_node_watch() in a loop.  If this fails in more than one iteration,
it can trip error_setv()'s assertion.

Fix by clearing @local_err.

Fixes: c4583c8c39 (xen-bus: reduce scope of backend watch)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20250314143500.2449658-2-armbru@redhat.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
Markus Armbruster 2025-03-14 15:34:59 +01:00
parent 1dd24ccf82
commit de7b18083b

View file

@ -357,6 +357,7 @@ static void xen_bus_realize(BusState *bus, Error **errp)
error_reportf_err(local_err, error_reportf_err(local_err,
"failed to set up '%s' enumeration watch: ", "failed to set up '%s' enumeration watch: ",
type[i]); type[i]);
local_err = NULL;
} }
g_free(node); g_free(node);