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/usb-msd.c | |
parent | 39508e7adb0de3ef69caa1b494d823d8ac11d3f3 (diff) |
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/usb-msd.c')
-rw-r--r-- | hw/usb-msd.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 003bd8a4cd..8e9718c562 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -531,6 +531,9 @@ static int usb_msd_initfn(USBDevice *dev) s->dev.speed = USB_SPEED_FULL; scsi_bus_new(&s->bus, &s->dev.qdev, 0, 1, usb_msd_command_complete); s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, s->conf.dinfo, 0); + if (!s->scsi_dev) { + return -1; + } s->bus.qbus.allow_hotplug = 0; usb_msd_handle_reset(dev); |