]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qom: Add error handler for object alias property
authorGonglei <arei.gonglei@huawei.com>
Sat, 27 Sep 2014 05:13:56 +0000 (13:13 +0800)
committerAndreas Färber <afaerber@suse.de>
Wed, 15 Oct 2014 03:03:04 +0000 (05:03 +0200)
object_property_add_alias() is called at some
places at present. And its parameter errp may not NULL,
such as
 object_property_add_alias(obj, "iothread", OBJECT(&dev->vdev),"iothread",
                              &error_abort);
This patch add error handler for security.

Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
qom/object.c

index 21135e1a08fc18f687313256fc4ed376f2eb3f39..575291f10958e8356460cd1fa5f13d9cc9704ffb 100644 (file)
@@ -1642,6 +1642,7 @@ void object_property_add_alias(Object *obj, const char *name,
     ObjectProperty *op;
     ObjectProperty *target_prop;
     gchar *prop_type;
+    Error *local_err = NULL;
 
     target_prop = object_property_find(target_obj, target_name, errp);
     if (!target_prop) {
@@ -1663,9 +1664,15 @@ void object_property_add_alias(Object *obj, const char *name,
                              property_get_alias,
                              property_set_alias,
                              property_release_alias,
-                             prop, errp);
+                             prop, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        g_free(prop);
+        goto out;
+    }
     op->resolve = property_resolve_alias;
 
+out:
     g_free(prop_type);
 }