summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2015-03-23 22:26:02 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2015-03-23 22:26:02 +0000
commitaed228c761d9dd414895329f7383a01c5fc7c3f2 (patch)
tree9c912658a781c5d56c6c488f46b946f8a2790360 /sys/dev/usb
parentf627dd5449e72440a913faad08e7bc60e7f2f141 (diff)
Return an error if getting the config descriptor failed.
Avoids a NULL dereference encountered with a device I have. ok mpi@
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/usb_subr.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index b5bcc17cd6f..dfdeaf99cd0 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_subr.c,v 1.116 2014/12/21 12:04:01 mpi Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.117 2015/03/23 22:26:01 jsg Exp $ */
/* $NetBSD: usb_subr.c,v 1.103 2003/01/10 11:19:13 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -1315,6 +1315,8 @@ usbd_get_cdesc(struct usbd_device *dev, int index, int *lenp)
if (index == USB_CURRENT_CONFIG_INDEX) {
tdesc = usbd_get_config_descriptor(dev);
+ if (tdesc == NULL)
+ return (NULL);
len = UGETW(tdesc->wTotalLength);
if (lenp)
*lenp = len;