summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2014-08-10 13:32:15 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2014-08-10 13:32:15 +0000
commit7978a82e6e497df03b51ebb18989a0a5560185e0 (patch)
tree1d7e0d6c3d138e90846da61b9887212d2c7a4400 /sys/dev
parent4f5e8a4930cff623270a8d67e13778210e091921 (diff)
Ask for the descriptor size corresponding to the number of ports present
in the hub, not from some random value from the stack.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/uhub.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c
index 6a2d90b61df..f2176ff4413 100644
--- a/sys/dev/usb/uhub.c
+++ b/sys/dev/usb/uhub.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhub.c,v 1.72 2014/08/09 09:58:11 mpi Exp $ */
+/* $OpenBSD: uhub.c,v 1.73 2014/08/10 13:32:14 mpi Exp $ */
/* $NetBSD: uhub.c,v 1.64 2003/02/08 03:32:51 ichiro Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */
@@ -143,17 +143,18 @@ uhub_attach(struct device *parent, struct device *self, void *aux)
/* Get hub descriptor. */
if (dev->speed == USB_SPEED_SUPER) {
err = usbd_get_hub_ss_descriptor(dev, &hd.ss, 1);
+ nports = hd.ss.bNbrPorts;
+ powerdelay = (hd.ss.bPwrOn2PwrGood * UHD_PWRON_FACTOR);
if (!err && nports > 7)
usbd_get_hub_ss_descriptor(dev, &hd.ss, nports);
} else {
err = usbd_get_hub_descriptor(dev, &hd.hs, 1);
+ nports = hd.hs.bNbrPorts;
+ powerdelay = (hd.hs.bPwrOn2PwrGood * UHD_PWRON_FACTOR);
if (!err && nports > 7)
usbd_get_hub_descriptor(dev, &hd.hs, nports);
}
- nports = hd.hs.bNbrPorts;
- powerdelay = (hd.hs.bPwrOn2PwrGood * UHD_PWRON_FACTOR);
-
if (err) {
DPRINTF("%s: getting hub descriptor failed, error=%s\n",
sc->sc_dev.dv_xname, usbd_errstr(err));