diff options
author | n_hibma <n_hibma@FreeBSD.org> | 2000-01-23 15:48:29 +0000 |
---|---|---|
committer | n_hibma <n_hibma@FreeBSD.org> | 2000-01-23 15:48:29 +0000 |
commit | 744b2db779eeb160fd4d27aa7948b336a48e6f8a (patch) | |
tree | cd76d124b16305d7209ca7acb39c49401c9579d7 /sys/dev | |
parent | 0f32b2a255bdc5f322d623b3fbde6c81ba91a1f9 (diff) | |
download | FreeBSD-src-744b2db779eeb160fd4d27aa7948b336a48e6f8a.zip FreeBSD-src-744b2db779eeb160fd4d27aa7948b336a48e6f8a.tar.gz |
Check whether we can change config at all. If any of the endpoints
has been opened, we should not allow configuration changes as endpoint
descriptors might disappear.
PR: 16256, 16168
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/ugen.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index f31b83b..e810440 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -204,6 +204,14 @@ ugen_set_config(sc, configno) DPRINTFN(1,("ugen_set_config: %s to configno %d, sc=%p\n", USBDEVNAME(sc->sc_dev), configno, sc)); + + /* We start at 1, not 0, because we don't care whether the + * control endpoint is open or not. It is always present. + */ + for (endptno = 1; endptno < USB_MAX_ENDPOINTS; endptno++) + if (sc->sc_is_open[endptno]) + return (USBD_IN_USE); + if (usbd_get_config_descriptor(dev)->bConfigurationValue != configno) { /* Avoid setting the current value. */ err = usbd_set_config_no(dev, configno, 0); @@ -949,7 +957,9 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p) if (!(flag & FWRITE)) return (EPERM); err = ugen_set_config(sc, *(int *)addr); - if (err) + if (err == USBD_IN_USE) + return(EBUSY); + else return (EIO); break; case USB_GET_ALTINTERFACE: |