diff options
-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; } |