hw/remote: guard listener unregister in finalize

Guard the unregister by checking whether the listener callback was
set, which only happens right before registration.

Cc: jag.raman@oracle.com
Fixes: c7d80c7c1d ("multi-process: Associate fd of a PCIDevice with its object")
Reviewed-by: Jagannathan Raman <jag.raman@oracle.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau
2026-04-25 01:00:30 +04:00
parent 4207565ea1
commit 52342c3067

View File

@@ -154,7 +154,9 @@ static void remote_object_finalize(Object *obj)
RemoteObjectClass *k = REMOTE_OBJECT_GET_CLASS(obj);
RemoteObject *o = REMOTE_OBJECT(obj);
device_listener_unregister(&o->listener);
if (o->listener.unrealize) {
device_listener_unregister(&o->listener);
}
if (o->ioc) {
qio_channel_shutdown(o->ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);