From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:59607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QJivN-0001y5-Pr for qemu-devel@nongnu.org; Tue, 10 May 2011 05:08:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QJivM-0000Iz-2j for qemu-devel@nongnu.org; Tue, 10 May 2011 05:08:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19836) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QJivL-0000Ie-QC for qemu-devel@nongnu.org; Tue, 10 May 2011 05:08:12 -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 p4A98AvV021689 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 10 May 2011 05:08:10 -0400 From: Gerd Hoffmann Date: Tue, 10 May 2011 11:08:06 +0200 Message-Id: <1305018486-16772-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1305018486-16772-1-git-send-email-kraxel@redhat.com> References: <1305018486-16772-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH] usb: mass storage fix List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Initialize scsi_len with zero when starting a new request, so any stuff leftover from the previous request is cleared out. This may happen in case the data returned by the scsi command doesn't fit into the buffer provided by the guest. Signed-off-by: Gerd Hoffmann (cherry picked from commit ef0bdf77d7070494692cbccd80c4c8f08c85c240) --- hw/usb-msd.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 76f5b02..d73216e 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -364,6 +364,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) DPRINTF("Command tag 0x%x flags %08x len %d data %d\n", s->tag, cbw.flags, cbw.cmd_len, s->data_len); s->residue = 0; + s->scsi_len = 0; s->scsi_dev->info->send_command(s->scsi_dev, s->tag, cbw.cmd, 0); /* ??? Should check that USB and SCSI data transfer directions match. */ -- 1.7.1