chardev: unref if underlying chardev has no parent
It's possible to write code creating a chardev backend that is not registered. When it is not user-created, it makes sense to keep it hidden. Let the associated frontend destroy it also in this case. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
43182856c5
commit
425d8a4e70
@ -235,7 +235,12 @@ void qemu_chr_fe_deinit(CharBackend *b, bool del)
|
|||||||
d->backends[b->tag] = NULL;
|
d->backends[b->tag] = NULL;
|
||||||
}
|
}
|
||||||
if (del) {
|
if (del) {
|
||||||
object_unparent(OBJECT(b->chr));
|
Object *obj = OBJECT(b->chr);
|
||||||
|
if (obj->parent) {
|
||||||
|
object_unparent(obj);
|
||||||
|
} else {
|
||||||
|
object_unref(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
b->chr = NULL;
|
b->chr = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user