Patchwork usb-storage: fix NULL pointer dereference.

login
register
mail settings
Submitter Gerd Hoffmann
Date Sept. 2, 2011, 11:36 a.m.
Message ID <1314963387-18612-1-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/113128/
State New
Headers show

Comments

Gerd Hoffmann - Sept. 2, 2011, 11:36 a.m.
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>
---
 hw/usb-msd.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index 591405b..b74c46e 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -315,7 +315,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)