]> git.proxmox.com Git - mirror_qemu.git/commitdiff
chardev: don't abort on attempt to add duplicated chardev
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 6 Jul 2020 18:10:34 +0000 (22:10 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 13 Jul 2020 07:59:47 +0000 (11:59 +0400)
This is a regression from commit d2623129a7d ("qom: Drop parameter @errp
of object_property_add() & friends").

(qemu) chardev-add id=null,backend=null
(qemu) chardev-add id=null,backend=null
Unexpected error in object_property_try_add() at /home/elmarco/src/qemu/qom/object.c:1166:
attempt to add duplicate property 'null' to object (type 'container')

That case is currently not covered in the test suite, but will be with
the queued patch "char: fix use-after-free with dup chardev &
reconnect".

Fixes: d2623129a7dec1d3041ad1221dda1ca49c667532
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
chardev/char.c

index e5b43cb4b87f0d6b342fe3af2fcd365987416368..a0626d04d5027d23c335e92263d536d9551c7f6c 100644 (file)
@@ -996,7 +996,11 @@ static Chardev *chardev_new(const char *id, const char *typename,
     }
 
     if (id) {
-        object_property_add_child(get_chardevs_root(), id, obj);
+        object_property_try_add_child(get_chardevs_root(), id, obj,
+                                      &local_err);
+        if (local_err) {
+            goto end;
+        }
         object_unref(obj);
     }