]> xenbits.xensource.com Git - qemu-upstream-4.6-testing.git/commitdiff
qdev: Fix crash by validating the object type
authorAmos Kong <akong@redhat.com>
Wed, 16 Apr 2014 01:57:14 +0000 (09:57 +0800)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Mon, 21 Jul 2014 03:14:21 +0000 (22:14 -0500)
QEMU crashed when I try to list device parameters and the driver name is
actually an available bus name.

 # qemu -device virtio-pci-bus,?
 # qemu -device virtio-bus,?
 # qemu -device virtio-serial-bus,?
 qdev-monitor.c:212:qdev_device_help: Object 0x7fd932f50620 is not an
 instance of type device
 Aborted (core dumped)

We can also reproduce this bug by adding device from monitor, so it's
worth to fix the crash.

 (qemu) device_add virtio-serial-bus
 qdev-monitor.c:491:qdev_device_add: Object 0x7f5e89530920 is not an
 instance of type device
 Aborted (core dumped)

Cc: qemu-stable@nongnu.org
Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
(cherry picked from commit ce0abca3e35a9f95e9edcb5d6b2910b2fcd52099)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qdev-monitor.c

index 9268c8759f144e9270e0daa787ba04d24403d71f..40c117dbd1816b5616276501df3fb8b47a3a9e60 100644 (file)
@@ -206,7 +206,7 @@ int qdev_device_help(QemuOpts *opts)
         }
     }
 
-    if (!klass) {
+    if (!object_class_dynamic_cast(klass, TYPE_DEVICE)) {
         return 0;
     }
     do {