usb/storage: clear csw on reset
authorGerd Hoffmann <kraxel@redhat.com>
Fri, 12 Mar 2021 09:49:54 +0000 (10:49 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 15 Mar 2021 16:01:17 +0000 (17:01 +0100)
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 <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210312094954.796799-1-kraxel@redhat.com>

hw/usb/dev-storage.c

index 7b587ad051ff095b6bed6850b4b20e95f1aa5491..dca62d544fe91022e9d81a6cd800bbb0a7919a31 100644 (file)
@@ -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;
 }