Message ID | 20180713130916.4153-4-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
Series | None | expand |
On Fri, Jul 13, 2018 at 03:08:50PM +0200, Marc-André Lureau wrote: > 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> > --- > chardev/char-fe.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel
diff --git a/chardev/char-fe.c b/chardev/char-fe.c index f158f158f8..a8931f7afd 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -235,7 +235,12 @@ void qemu_chr_fe_deinit(CharBackend *b, bool del) d->backends[b->tag] = NULL; } 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; }
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> --- chardev/char-fe.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)