USB: fix usb open suspend race in cdc-acm
this fixes a race between open and disconnect in the CDC ACM driver. Signed-off-by: Oliver Neukum <oneukum@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
59036e9473
commit
94409cc1e5
@ -496,13 +496,10 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
|
|||||||
otherwise it is scheduled, and with high data rates data can get lost. */
|
otherwise it is scheduled, and with high data rates data can get lost. */
|
||||||
tty->low_latency = 1;
|
tty->low_latency = 1;
|
||||||
|
|
||||||
if (usb_autopm_get_interface(acm->control)) {
|
if (usb_autopm_get_interface(acm->control) < 0)
|
||||||
mutex_unlock(&open_mutex);
|
goto early_bail;
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex_lock(&acm->mutex);
|
mutex_lock(&acm->mutex);
|
||||||
mutex_unlock(&open_mutex);
|
|
||||||
if (acm->used++) {
|
if (acm->used++) {
|
||||||
usb_autopm_put_interface(acm->control);
|
usb_autopm_put_interface(acm->control);
|
||||||
goto done;
|
goto done;
|
||||||
@ -536,6 +533,7 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
|
|||||||
done:
|
done:
|
||||||
err_out:
|
err_out:
|
||||||
mutex_unlock(&acm->mutex);
|
mutex_unlock(&acm->mutex);
|
||||||
|
mutex_unlock(&open_mutex);
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
full_bailout:
|
full_bailout:
|
||||||
@ -544,6 +542,8 @@ bail_out:
|
|||||||
usb_autopm_put_interface(acm->control);
|
usb_autopm_put_interface(acm->control);
|
||||||
acm->used--;
|
acm->used--;
|
||||||
mutex_unlock(&acm->mutex);
|
mutex_unlock(&acm->mutex);
|
||||||
|
early_bail:
|
||||||
|
mutex_unlock(&open_mutex);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user