summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/umass.c
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2020-11-23 21:33:37 +0000
committerkrw <krw@openbsd.org>2020-11-23 21:33:37 +0000
commit88e48fc9892112ea04dc8cb14bc94e8645477f62 (patch)
tree2b903b797c1bb41ded3304a3eb2ad69c06424352 /sys/dev/usb/umass.c
parentIgnore duplicate sigsha2 notify, don't fail the exchange. (diff)
downloadwireguard-openbsd-88e48fc9892112ea04dc8cb14bc94e8645477f62.tar.xz
wireguard-openbsd-88e48fc9892112ea04dc8cb14bc94e8645477f62.zip
Adopt a Linux heuristic and mark as IGNORE_RESIDUE those umass(4)
devices whose INQUIRY command succeeds but with a residue equal to the requested bytes. Subsequent i/o's (including the INQUIRY) which succeed with a residue equal to the requested bytes will have residue set to 0. Fixes (very?) old devices such as the memory stick Andrew Daugherity pulled out of his drawer and with which he hoped to install 6.8. Subsequent testing of diffs much appreciated!
Diffstat (limited to 'sys/dev/usb/umass.c')
-rw-r--r--sys/dev/usb/umass.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/dev/usb/umass.c b/sys/dev/usb/umass.c
index de23c439817..cb549b6beeb 100644
--- a/sys/dev/usb/umass.c
+++ b/sys/dev/usb/umass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: umass.c,v 1.78 2020/09/05 14:21:52 krw Exp $ */
+/* $OpenBSD: umass.c,v 1.79 2020/11/23 21:33:37 krw Exp $ */
/* $NetBSD: umass.c,v 1.116 2004/06/30 05:53:46 mycroft Exp $ */
/*
@@ -1299,8 +1299,17 @@ umass_bbb_state(struct usbd_xfer *xfer, void *priv, usbd_status err)
return;
} else { /* success */
+ u_int32_t residue = UGETDW(sc->csw.dCSWDataResidue);
sc->transfer_state = TSTATE_IDLE;
if (sc->transfer_dir == DIR_IN) {
+ if (residue == sc->transfer_datalen) {
+ if (sc->cbw.CBWCDB[0] == INQUIRY)
+ SET(sc->sc_quirks,
+ UMASS_QUIRK_IGNORE_RESIDUE);
+ if (ISSET(sc->sc_quirks,
+ UMASS_QUIRK_IGNORE_RESIDUE))
+ USETDW(sc->csw.dCSWDataResidue, 0);
+ }
sc->transfer_actlen = sc->transfer_datalen -
UGETDW(sc->csw.dCSWDataResidue);
memcpy(sc->transfer_data, sc->data_buffer,