Module Name:    src
Committed By:   skrll
Date:           Fri Jun 26 16:19:28 UTC 2015

Modified Files:
        src/sys/dev/usb [nick-nhusb]: usb_subr.c

Log Message:
Don't give doing SET_CONFIG if usbd_set_config_index fails to get the
full BOS descriptor.  Mark ud_bdesc as NULL instead


To generate a diff of this commit:
cvs rdiff -u -r1.198.2.15 -r1.198.2.16 src/sys/dev/usb/usb_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.198.2.15 src/sys/dev/usb/usb_subr.c:1.198.2.16
--- src/sys/dev/usb/usb_subr.c:1.198.2.15	Sat Jun  6 15:26:15 2015
+++ src/sys/dev/usb/usb_subr.c	Fri Jun 26 16:19:28 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_subr.c,v 1.198.2.15 2015/06/06 15:26:15 skrll Exp $	*/
+/*	$NetBSD: usb_subr.c,v 1.198.2.16 2015/06/26 16:19:28 skrll Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.198.2.15 2015/06/06 15:26:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.198.2.16 2015/06/26 16:19:28 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -602,36 +602,30 @@ usbd_set_config_index(struct usbd_device
 	}
 
 	if (USB_IS_SS(dev->ud_speed)) {
-		int blen;
-
 		/* get short bos desc */
 		err = usbd_get_bos_desc(dev, index, &bd);
-		if (err) {
-			DPRINTF("get_bos_desc=%d", err, 0, 0, 0);
-			goto bad;
-		}
-		blen = UGETW(bd.wTotalLength);
-		bdp = kmem_alloc(blen, KM_SLEEP);
-		if (bdp == NULL) {
-			err = USBD_NOMEM;
-			goto bad;
-		}
+		if (!err) {
+			int blen = UGETW(bd.wTotalLength);
+			bdp = kmem_alloc(blen, KM_SLEEP);
+			if (bdp == NULL) {
+				err = USBD_NOMEM;
+				goto bad;
+			}
 
-		/* Get the full desc */
-		for (i = 0; i < 3; i++) {
-			err = usbd_get_desc(dev, UDESC_BOS, index, blen, bdp);
-			if (!err)
-				break;
-			usbd_delay_ms(dev, 200);
-		}
-		if (err) {
-			DPRINTF("get_bos_desc=%d", err, 0, 0, 0);
-			goto bad;
-		}
-		if (bdp->bDescriptorType != UDESC_BOS) {
-			DPRINTF("bad desc %d", bdp->bDescriptorType, 0, 0, 0);
-			err = USBD_INVAL;
-			goto bad;
+			/* Get the full desc */
+			for (i = 0; i < 3; i++) {
+				err = usbd_get_desc(dev, UDESC_BOS, index, blen,
+				    bdp);
+				if (!err)
+					break;
+				usbd_delay_ms(dev, 200);
+			}
+			if (err || bdp->bDescriptorType != UDESC_BOS) {
+				DPRINTF("error %d or bad desc %d", err,
+				    bdp->bDescriptorType, 0, 0);
+				kmem_free(bdp, blen);
+				bdp = NULL;
+			}
 		}
 	}
 	dev->ud_bdesc = bdp;

Reply via email to