diff options
author | Markus Armbruster <armbru@redhat.com> | 2010-06-25 18:53:21 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2010-07-02 13:18:01 +0200 |
commit | fa66b909f382619da15f8c7e323145adfa94fdac (patch) | |
tree | ad7e6948ea9eafbd78633a6d14d25cb5c90a88f1 /hw/pci-hotplug.c | |
parent | 39508e7adb0de3ef69caa1b494d823d8ac11d3f3 (diff) | |
download | qemu-fa66b909f382619da15f8c7e323145adfa94fdac.zip qemu-fa66b909f382619da15f8c7e323145adfa94fdac.tar.gz qemu-fa66b909f382619da15f8c7e323145adfa94fdac.tar.bz2 |
scsi: scsi_bus_legacy_handle_cmdline() can fail, fix callers
None of its callers checks for failure. scsi_hot_add() can crash
because of that:
(qemu) drive_add 4 if=scsi,format=host_device,file=/dev/sg1
scsi-generic: scsi generic interface too old
Segmentation fault (core dumped)
Fix all callers, not just scsi_hot_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/pci-hotplug.c')
-rw-r--r-- | hw/pci-hotplug.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index c39e640..55c9fe3 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -90,6 +90,9 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter, */ dinfo->unit = qemu_opt_get_number(dinfo->opts, "unit", -1); scsidev = scsi_bus_legacy_add_drive(scsibus, dinfo, dinfo->unit); + if (!scsidev) { + return -1; + } dinfo->unit = scsidev->id; if (printinfo) |