diff options
| author | maxv <maxv@NetBSD.org> | 2019-11-17 11:28:48 +0000 |
|---|---|---|
| committer | maxv <maxv@NetBSD.org> | 2019-11-17 11:28:48 +0000 |
| commit | 022cee7f45b4e1e8dd1688c10ceae4bd2635bf48 (patch) | |
| tree | 61c3ea4549f8c3dc60936c3a46e6ad37a50a1e67 /sys/dev | |
| parent | 86432df29b3c0dec35647460c5a952c728d06e65 (diff) | |
Not a bug strictly speaking, but compute the address only after the length
checks, for clarity and to appease kUBSan.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/usb/vhci.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/dev/usb/vhci.c b/sys/dev/usb/vhci.c index 94ea96bea2c..0061779b981 100644 --- a/sys/dev/usb/vhci.c +++ b/sys/dev/usb/vhci.c @@ -1,4 +1,4 @@ -/* $NetBSD: vhci.c,v 1.3 2019/10/03 05:13:23 maxv Exp $ */ +/* $NetBSD: vhci.c,v 1.4 2019/11/17 11:28:48 maxv Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.3 2019/10/03 05:13:23 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.4 2019/11/17 11:28:48 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -376,8 +376,6 @@ vhci_roothub_ctrl(struct usbd_bus *bus, usb_device_request_t *req, value = UGETW(req->wValue); index = UGETW(req->wIndex); - port = &sc->sc_port[VHCI_INDEX2PORT(index)]; - #define C(x,y) ((x) | ((y) << 8)) switch (C(req->bRequest, req->bmRequestType)) { case C(UR_GET_DESCRIPTOR, UT_READ_DEVICE): @@ -414,6 +412,7 @@ vhci_roothub_ctrl(struct usbd_bus *bus, usb_device_request_t *req, if (index < 1 || index >= sc->sc_nports) { return -1; } + port = &sc->sc_port[VHCI_INDEX2PORT(index)]; port->status |= UPS_C_PORT_RESET; break; case UHF_PORT_POWER: @@ -430,6 +429,7 @@ vhci_roothub_ctrl(struct usbd_bus *bus, usb_device_request_t *req, if (index < 1 || index >= sc->sc_nports) { return -1; } + port = &sc->sc_port[VHCI_INDEX2PORT(index)]; switch (value) { case UHF_PORT_ENABLE: port->status &= ~UPS_PORT_ENABLED; @@ -463,6 +463,7 @@ vhci_roothub_ctrl(struct usbd_bus *bus, usb_device_request_t *req, if (index < 1 || index >= sc->sc_nports) { return -1; } + port = &sc->sc_port[VHCI_INDEX2PORT(index)]; USETW(ps.wPortStatus, port->status); USETW(ps.wPortChange, port->change); totlen = uimin(len, sizeof(ps)); |
