Skip to contentSkip to conversation

usb/storage: clear csw on reset

PATCH In review Gerd Hoffmann 2 participants 2 messages Mar 12, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb/storage: clear csw on reset

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.

---
 hw/usb/dev-storage.c | 1 +
 1 file changed, 1 insertion(+)
hw/usb/dev-storage.c +1 -0
index a5f76fc00120..fd4ea818115c 100644
@@ -352,6 +352,7 @@ static void usb_msd_handle_reset(USBDevice *dev)
         usb_msd_packet_complete(s);
     }
 
+    memset(&s->csw, 0, sizeof(s->csw));
     s->mode = USB_MSDM_CBW;
 }
 
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Gerd Hoffmann

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.

---
 hw/usb/dev-storage.c | 1 +
 1 file changed, 1 insertion(+)
hw/usb/dev-storage.c +0 -0
index a5f76fc00120..fd4ea818115c 100644

hw/usb/dev-storage.c static void usb_msd_handle_reset(USBDevice *dev) · line 355

Quoted 4 lines
hw/usb/dev-storage.c +1 -0
@@ -352,6 +352,7 @@ static void usb_msd_handle_reset(USBDevice *dev)
         usb_msd_packet_complete(s);
     }
 
+    memset(&s->csw, 0, sizeof(s->csw));

easy-peasy...

Quoted 2 lines
hw/usb/dev-storage.c +0 -0
     s->mode = USB_MSDM_CBW;
 }