From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:57866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QM3uK-0005XK-U5 for qemu-devel@nongnu.org; Mon, 16 May 2011 15:56:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QM3uK-0004PF-2k for qemu-devel@nongnu.org; Mon, 16 May 2011 15:56:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26371) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QM3uJ-0004Oy-Rm for qemu-devel@nongnu.org; Mon, 16 May 2011 15:56:48 -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 p4GJulQc007592 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 16 May 2011 15:56:47 -0400 From: Gerd Hoffmann Date: Mon, 16 May 2011 21:56:21 +0200 Message-Id: <1305575782-31766-18-git-send-email-kraxel@redhat.com> In-Reply-To: <1305575782-31766-1-git-send-email-kraxel@redhat.com> References: <1305575782-31766-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 17/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 7a08358..141da2c 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