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
This commit is contained in:
n_hibma 2000-01-23 15:48:29 +00:00
parent 0f32b2a255
commit 744b2db779

View File

@ -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: