diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2018-07-11 20:00:19 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2018-10-03 14:45:04 +0400 |
commit | 425d8a4e70f3946ac649925c4e3211906371ca6d (patch) | |
tree | 13010b144fa54cc4a9eeb67d9420ff3ef89ecfdb /chardev/char-fe.c | |
parent | 43182856c5a576f5db5f40768972a19f187a789e (diff) |
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>
Diffstat (limited to 'chardev/char-fe.c')
-rw-r--r-- | chardev/char-fe.c | 7 |
1 files changed, 6 insertions, 1 deletions
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; } |