Skip to content

Commit

Permalink
qdev: Fix crash by validating the object type
Browse files Browse the repository at this point in the history
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: [email protected]
Signed-off-by: Amos Kong <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Andreas Färber <[email protected]>
  • Loading branch information
amoskong authored and afaerber committed May 5, 2014
1 parent fdaad47 commit ce0abca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion qdev-monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ int qdev_device_help(QemuOpts *opts)
}
}

if (!klass) {
if (!object_class_dynamic_cast(klass, TYPE_DEVICE)) {
return 0;
}
do {
Expand Down

0 comments on commit ce0abca

Please sign in to comment.