summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-01-09 12:15:49 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-01-09 12:15:49 +0000
commitab1aaf860e72550ba75b8cc805e81601ef51f662 (patch)
tree26d42b73d5760e5a3abb5b40972c3fcea311e46d
parent26e68c677f6a2c5e8e4e2ab1427d4ffe57f625fc (diff)
Always check for DMA buffer overrun, not just for some specific xfers.
-rw-r--r--sys/dev/usb/usbdi.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c
index e875158358e..53b9240c4cf 100644
--- a/sys/dev/usb/usbdi.c
+++ b/sys/dev/usb/usbdi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdi.c,v 1.76 2015/01/09 12:07:50 mpi Exp $ */
+/* $OpenBSD: usbdi.c,v 1.77 2015/01/09 12:15:48 mpi Exp $ */
/* $NetBSD: usbdi.c,v 1.103 2002/09/27 15:37:38 provos Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */
@@ -731,15 +731,15 @@ usb_transfer_complete(struct usbd_xfer *xfer)
if (polling)
pipe->running = 0;
- if (!(xfer->flags & USBD_NO_COPY) && xfer->actlen != 0 &&
- usbd_xfer_isread(xfer)) {
#ifdef DIAGNOSTIC
- if (xfer->actlen > xfer->length) {
- printf("usb_transfer_complete: actlen > len %u > %u\n",
- xfer->actlen, xfer->length);
- xfer->actlen = xfer->length;
- }
+ if (xfer->actlen > xfer->length) {
+ printf("%s: actlen > len %u > %u\n", __func__, xfer->actlen,
+ xfer->length);
+ xfer->actlen = xfer->length;
+ }
#endif
+ if (!(xfer->flags & USBD_NO_COPY) && xfer->actlen != 0 &&
+ usbd_xfer_isread(xfer)) {
memcpy(xfer->buffer, KERNADDR(&xfer->dmabuf, 0), xfer->actlen);
}
@@ -904,15 +904,6 @@ usbd_do_request_flags(struct usbd_device *dev, usb_device_request_t *req,
usbd_setup_default_xfer(xfer, dev, 0, timeout, req, data,
UGETW(req->wLength), flags | USBD_SYNCHRONOUS, 0);
err = usbd_transfer(xfer);
-#if defined(USB_DEBUG) || defined(DIAGNOSTIC)
- if (xfer->actlen > xfer->length)
- DPRINTF(("usbd_do_request: overrun addr=%d type=0x%02x req=0x"
- "%02x val=%d index=%d rlen=%d length=%d actlen=%d\n",
- dev->address, xfer->request.bmRequestType,
- xfer->request.bRequest, UGETW(xfer->request.wValue),
- UGETW(xfer->request.wIndex), UGETW(xfer->request.wLength),
- xfer->length, xfer->actlen));
-#endif
if (actlen != NULL)
*actlen = xfer->actlen;
if (err == USBD_STALLED) {
@@ -961,15 +952,6 @@ void
usbd_do_request_async_cb(struct usbd_xfer *xfer, void *priv,
usbd_status status)
{
-#if defined(USB_DEBUG) || defined(DIAGNOSTIC)
- if (xfer->actlen > xfer->length)
- DPRINTF(("usbd_do_request: overrun addr=%d type=0x%02x req=0x"
- "%02x val=%d index=%d rlen=%d length=%d actlen=%d\n",
- xfer->pipe->device->address, xfer->request.bmRequestType,
- xfer->request.bRequest, UGETW(xfer->request.wValue),
- UGETW(xfer->request.wIndex), UGETW(xfer->request.wLength),
- xfer->length, xfer->actlen));
-#endif
usbd_free_xfer(xfer);
}