diff options
| -rw-r--r-- | sys/dev/usb/usbdi.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c index 1ce6fd1f0d4d..83b1fe68b0f2 100644 --- a/sys/dev/usb/usbdi.c +++ b/sys/dev/usb/usbdi.c @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.c,v 1.71 2000/03/29 01:45:21 augustss Exp $ */ +/* $NetBSD: usbdi.c,v 1.73 2000/05/31 16:14:42 augustss Exp $ */ /* $FreeBSD$ */ /* @@ -635,6 +635,12 @@ usbd_endpoint_count(iface, count) usbd_interface_handle iface; u_int8_t *count; { +#ifdef DIAGNOSTIC + if (iface == NULL || iface->idesc == NULL) { + printf("usbd_endpoint_count: NULL pointer\n"); + return (USBD_INVAL); + } +#endif *count = iface->idesc->bNumEndpoints; return (USBD_NORMAL_COMPLETION); } @@ -688,19 +694,27 @@ usbd_set_interface(iface, altidx) { usb_device_request_t req; usbd_status err; + void *endpoints; if (LIST_FIRST(&iface->pipes) != 0) return (USBD_IN_USE); - if (iface->endpoints) - free(iface->endpoints, M_USB); - iface->endpoints = 0; - iface->idesc = 0; - + endpoints = iface->endpoints; err = usbd_fill_iface_data(iface->device, iface->index, altidx); if (err) return (err); + /* new setting work, we can free old endpoints */ + if (endpoints != NULL) + free(endpoints, M_USB); + +#ifdef DIAGNOSTIC + if (iface->idesc == NULL) { + printf("usbd_set_interface: NULL pointer\n"); + return (USBD_INVAL); + } +#endif + req.bmRequestType = UT_WRITE_INTERFACE; req.bRequest = UR_SET_INTERFACE; USETW(req.wValue, iface->idesc->bAlternateSetting); |
