From: Amos Kong Date: Wed, 16 Apr 2014 01:57:14 +0000 (+0800) Subject: qdev: Fix crash by validating the object type X-Git-Tag: qemu-xen-4.5.0-rc1^2~85 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=837e02ef07179876ca2ada2ed67d3eeaa9d3a9d7;p=qemu-upstream-4.5-testing.git qdev: Fix crash by validating the object type 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 Reviewed-by: Markus Armbruster Signed-off-by: Andreas Färber (cherry picked from commit ce0abca3e35a9f95e9edcb5d6b2910b2fcd52099) Signed-off-by: Michael Roth --- diff --git a/qdev-monitor.c b/qdev-monitor.c index 9268c8759..40c117dbd 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -206,7 +206,7 @@ int qdev_device_help(QemuOpts *opts) } } - if (!klass) { + if (!object_class_dynamic_cast(klass, TYPE_DEVICE)) { return 0; } do {