]> git.proxmox.com Git - qemu.git/commitdiff
QOM: Fail casts for unknown types
authorAlexander Graf <agraf@suse.de>
Tue, 30 Apr 2013 13:02:16 +0000 (15:02 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 30 Apr 2013 14:40:11 +0000 (09:40 -0500)
When we try to cast an object to an unknown type, fail the cast. Today
we would simply run into an assert().

This fixes a bug on qemu-system-s390x for me that gets triggered by the
audio code looking for PCI and ISA buses.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1367326936-28539-1-git-send-email-agraf@suse.de
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qom/object.c

index dd53d242a5cffe6810cf6b315ee5f6efa56d3316..75e6aac15febacdb5c3045dcef8dffe1fe5b78bb 100644 (file)
@@ -453,6 +453,11 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class,
     TypeImpl *type = class->type;
     ObjectClass *ret = NULL;
 
+    if (!target_type) {
+        /* target class type unknown, so fail the cast */
+        return NULL;
+    }
+
     if (type->class->interfaces &&
             type_is_ancestor(target_type, type_interface)) {
         int found = 0;