diff options
author | joe <joe@FreeBSD.org> | 2002-05-23 00:36:14 +0000 |
---|---|---|
committer | joe <joe@FreeBSD.org> | 2002-05-23 00:36:14 +0000 |
commit | b4f31d6da41b4104cde3503e1ddd2658e8443493 (patch) | |
tree | 6e0b40421195470fc0a7761c478b9145bd775878 | |
parent | 4fe0504ac98cad7ad7323ec4abdcaebff302914f (diff) | |
download | FreeBSD-src-b4f31d6da41b4104cde3503e1ddd2658e8443493.zip FreeBSD-src-b4f31d6da41b4104cde3503e1ddd2658e8443493.tar.gz |
Fix a panic by allocating the iface structure locally in the attach
function instead of in usb_probe_and_attach.
-rw-r--r-- | sys/dev/usb/if_aue.c | 16 | ||||
-rw-r--r-- | sys/dev/usb/if_auereg.h | 1 |
2 files changed, 14 insertions, 3 deletions
diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c index 44614d5..ca5e517 100644 --- a/sys/dev/usb/if_aue.c +++ b/sys/dev/usb/if_aue.c @@ -618,7 +618,7 @@ USB_MATCH(aue) USB_MATCH_START(aue, uaa); struct aue_type *t; - if (uaa->iface == NULL) + if (uaa->iface != NULL) return (UMATCH_NONE); t = aue_devs; @@ -643,6 +643,8 @@ USB_ATTACH(aue) char devinfo[1024]; u_char eaddr[ETHER_ADDR_LEN]; struct ifnet *ifp; + usbd_interface_handle iface; + usbd_status err; usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed; int i; @@ -652,7 +654,6 @@ USB_ATTACH(aue) usbd_devinfo(uaa->device, 0, devinfo); - sc->aue_iface = uaa->iface; sc->aue_udev = uaa->device; sc->aue_unit = device_get_unit(self); @@ -662,6 +663,15 @@ USB_ATTACH(aue) USB_ATTACH_ERROR_RETURN; } + err = usbd_device2interface_handle(uaa->device, AUE_IFACE_IDX, &iface); + if (err) { + printf("aue%d: getting interface handle failed\n", + sc->aue_unit); + USB_ATTACH_ERROR_RETURN; + } + + sc->aue_iface = iface; + t = aue_devs; while(t->aue_vid) { if (uaa->vendor == t->aue_vid && @@ -680,7 +690,7 @@ USB_ATTACH(aue) /* Find endpoints. */ for (i = 0; i < id->bNumEndpoints; i++) { - ed = usbd_interface2endpoint_descriptor(uaa->iface, i); + ed = usbd_interface2endpoint_descriptor(iface, i); if (ed == NULL) { printf("aue%d: couldn't get ep %d\n", sc->aue_unit, i); diff --git a/sys/dev/usb/if_auereg.h b/sys/dev/usb/if_auereg.h index 59914ec..4c45285 100644 --- a/sys/dev/usb/if_auereg.h +++ b/sys/dev/usb/if_auereg.h @@ -50,6 +50,7 @@ #define AUE_UR_WRITEREG 0xF1 #define AUE_CONFIG_NO 1 +#define AUE_IFACE_IDX 0 /* * Note that while the ADMtek technically has four |