From 39912c14da07a2dbc73854addcfa0a42596340ac Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 12 Mar 2021 10:49:54 +0100 Subject: [PATCH] usb/storage: clear csw on reset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stale data in csw (specifically residue) can confuse the state machine and allows the guest trigger an assert(). So clear csw on reset to avoid this happening in case the guest resets the device in the middle of a request. Buglink: https://bugs.launchpad.net/qemu/+bug/1523811 Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20210312094954.796799-1-kraxel@redhat.com> --- hw/usb/dev-storage.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 7b587ad051..dca62d544f 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -313,6 +313,7 @@ void usb_msd_handle_reset(USBDevice *dev) usb_msd_packet_complete(s); } + memset(&s->csw, 0, sizeof(s->csw)); s->mode = USB_MSDM_CBW; }