usb-storage: fix NULL pointer dereference.

When a usb packet is canceled we need to check whenever we actually have
a scsi request in flight before we try to cancel it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2011-09-02 13:05:13 +02:00
parent ebffe2afce
commit d3ac1a87b2
1 changed files with 4 additions and 1 deletions

View File

@ -325,7 +325,10 @@ static int usb_msd_handle_control(USBDevice *dev, USBPacket *p,
static void usb_msd_cancel_io(USBDevice *dev, USBPacket *p)
{
MSDState *s = DO_UPCAST(MSDState, dev, dev);
scsi_req_cancel(s->req);
if (s->req) {
scsi_req_cancel(s->req);
}
}
static int usb_msd_handle_data(USBDevice *dev, USBPacket *p)