From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QORg1-0001K1-Pj for qemu-devel@nongnu.org; Mon, 23 May 2011 05:43:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QORfx-0007hR-Sr for qemu-devel@nongnu.org; Mon, 23 May 2011 05:43:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43418) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QORfx-0007hA-Hb for qemu-devel@nongnu.org; Mon, 23 May 2011 05:43:49 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4N9hm2Q003590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 23 May 2011 05:43:48 -0400 From: Gerd Hoffmann Date: Mon, 23 May 2011 11:43:35 +0200 Message-Id: <1306143819-30287-15-git-send-email-kraxel@redhat.com> In-Reply-To: <1306143819-30287-1-git-send-email-kraxel@redhat.com> References: <1306143819-30287-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 14/18] usb-storage: don't call usb_packet_complete twice List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann usb_msd_copy_data() may cause a recursive call to usb_msd_command_complete() which in turn may complete the packet, setting s->packet to NULL in case it does. Recheck s->packet before calling usb_packet_complete() to fix the double call. Signed-off-by: Gerd Hoffmann --- hw/usb-msd.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index c3a197a..1064920 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -253,7 +253,7 @@ static void usb_msd_command_complete(SCSIBus *bus, int reason, uint32_t tag, s->scsi_buf = s->scsi_dev->info->get_buf(s->scsi_dev, tag); if (p) { usb_msd_copy_data(s); - if (s->usb_len == 0) { + if (s->packet && s->usb_len == 0) { /* Set s->packet to NULL before calling usb_packet_complete because another request may be issued before usb_packet_complete returns. */ -- 1.7.1