From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:49391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzS2z-0006Aj-4q for qemu-devel@nongnu.org; Fri, 02 Sep 2011 07:36:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QzS2y-0006BY-9p for qemu-devel@nongnu.org; Fri, 02 Sep 2011 07:36:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57641) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzS2x-0006BR-UT for qemu-devel@nongnu.org; Fri, 02 Sep 2011 07:36:32 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p82BaU9w005030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 2 Sep 2011 07:36:30 -0400 From: Gerd Hoffmann Date: Fri, 2 Sep 2011 13:36:27 +0200 Message-Id: <1314963387-18612-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH] usb-storage: fix NULL pointer dereference. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann 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 --- hw/usb-msd.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) 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) -- 1.7.1