summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2012-05-12 17:27:45 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2012-05-12 17:27:45 +0000
commit497409d8544d5d8fbc62b93f979d51115fe1bd84 (patch)
treed26bb589309f92ad8c4b5d1388b44ef3e7eb0217
parent90436b58e03d7444a8bb97ee100d2a8d2ec8cd9a (diff)
Returns different errors for USB_REQUEST if the address specified
is invalid or valid but with no device found. ok miod@
-rw-r--r--sys/dev/usb/usb.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index 6b8ce5782f3..d2d256fe750 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb.c,v 1.79 2012/01/28 00:40:23 deraadt Exp $ */
+/* $OpenBSD: usb.c,v 1.80 2012/05/12 17:27:44 mpi Exp $ */
/* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */
/*
@@ -551,9 +551,10 @@ usbioctl(dev_t devt, u_long cmd, caddr_t data, int flag, struct proc *p)
DPRINTF(("usbioctl: USB_REQUEST addr=%d len=%d\n", addr, len));
if (len < 0 || len > 32768)
return (EINVAL);
- if (addr < 0 || addr >= USB_MAX_DEVICES ||
- sc->sc_bus->devices[addr] == 0)
+ if (addr < 0 || addr >= USB_MAX_DEVICES)
return (EINVAL);
+ if (sc->sc_bus->devices[addr] == NULL)
+ return (ENXIO);
if (len != 0) {
iov.iov_base = (caddr_t)ur->ucr_data;
iov.iov_len = len;