diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2019-01-13 14:27:16 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2019-01-13 14:27:16 +0000 |
commit | 76b400942053aa7b0151b68e44785a5b3d58e4a2 (patch) | |
tree | 3cdfcc73907e66c986e1c445a351c54e2a8c4031 /sys/dev/usb | |
parent | 26fb3a0e60f4b8964ceeb3fef90852ae0de59a51 (diff) |
Validate that the interface passed to *match() is the expected one
instead of calling usbd_device2interface_handle() during *attach().
ok stsp@
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/if_ral.c | 15 | ||||
-rw-r--r-- | sys/dev/usb/if_ralreg.h | 4 |
2 files changed, 5 insertions, 14 deletions
diff --git a/sys/dev/usb/if_ral.c b/sys/dev/usb/if_ral.c index 66ded63552f..d3f68b91c85 100644 --- a/sys/dev/usb/if_ral.c +++ b/sys/dev/usb/if_ral.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ral.c,v 1.144 2017/10/26 15:00:28 mpi Exp $ */ +/* $OpenBSD: if_ral.c,v 1.145 2019/01/13 14:27:15 mpi Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -196,7 +196,7 @@ ural_match(struct device *parent, void *match, void *aux) { struct usb_attach_arg *uaa = aux; - if (uaa->iface == NULL || uaa->configno != RAL_CONFIG_NO) + if (uaa->configno != RAL_CONFIG_NO || uaa->ifaceno != RAL_IFACE_NO) return UMATCH_NONE; return (usb_lookup(ural_devs, uaa->vendor, uaa->product) != NULL) ? @@ -212,19 +212,10 @@ ural_attach(struct device *parent, struct device *self, void *aux) struct ifnet *ifp = &ic->ic_if; usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed; - usbd_status error; int i; sc->sc_udev = uaa->device; - - /* get the first interface handle */ - error = usbd_device2interface_handle(sc->sc_udev, RAL_IFACE_INDEX, - &sc->sc_iface); - if (error != 0) { - printf("%s: could not get interface handle\n", - sc->sc_dev.dv_xname); - return; - } + sc->sc_iface = uaa->iface; /* * Find endpoints. diff --git a/sys/dev/usb/if_ralreg.h b/sys/dev/usb/if_ralreg.h index 34bff016ab6..56771376e32 100644 --- a/sys/dev/usb/if_ralreg.h +++ b/sys/dev/usb/if_ralreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ralreg.h,v 1.13 2013/11/26 20:33:18 deraadt Exp $ */ +/* $OpenBSD: if_ralreg.h,v 1.14 2019/01/13 14:27:15 mpi Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -21,7 +21,7 @@ #define RAL_TX_DESC_SIZE (sizeof (struct ural_tx_desc)) #define RAL_CONFIG_NO 1 -#define RAL_IFACE_INDEX 0 +#define RAL_IFACE_NO 0 #define RAL_WRITE_MAC 0x02 #define RAL_READ_MAC 0x03 |