1

usb: cdc-acm: move ldisc dcd notification outside of acm's read lock

dcd_change notification call moved outside of the acm->read_lock
to protect any future tty ldisc that calls wait_serial_change()

Signed-off-by: Dan Drown <dan-netdev@drown.org>
Acked-by: Oliver Neukum <oneukum@suse.com>
Link: https://lore.kernel.org/r/ZN1zV/zjPgpGlHXo@vps3.drown.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Dan Drown 2023-08-16 20:09:43 -05:00 committed by Greg Kroah-Hartman
parent 23e60c8daf
commit f72ae60881

View File

@ -319,23 +319,24 @@ static void acm_process_notification(struct acm *acm, unsigned char *buf)
} }
difference = acm->ctrlin ^ newctrl; difference = acm->ctrlin ^ newctrl;
if ((difference & USB_CDC_SERIAL_STATE_DCD) && acm->port.tty) {
struct tty_ldisc *ld = tty_ldisc_ref(acm->port.tty);
if (ld) {
if (ld->ops->dcd_change)
ld->ops->dcd_change(acm->port.tty, newctrl & USB_CDC_SERIAL_STATE_DCD);
tty_ldisc_deref(ld);
}
}
spin_lock_irqsave(&acm->read_lock, flags); spin_lock_irqsave(&acm->read_lock, flags);
acm->ctrlin = newctrl; acm->ctrlin = newctrl;
acm->oldcount = acm->iocount; acm->oldcount = acm->iocount;
if (difference & USB_CDC_SERIAL_STATE_DSR) if (difference & USB_CDC_SERIAL_STATE_DSR)
acm->iocount.dsr++; acm->iocount.dsr++;
if (difference & USB_CDC_SERIAL_STATE_DCD) { if (difference & USB_CDC_SERIAL_STATE_DCD)
if (acm->port.tty) {
struct tty_ldisc *ld = tty_ldisc_ref(acm->port.tty);
if (ld) {
if (ld->ops->dcd_change)
ld->ops->dcd_change(acm->port.tty, newctrl & USB_CDC_SERIAL_STATE_DCD);
tty_ldisc_deref(ld);
}
}
acm->iocount.dcd++; acm->iocount.dcd++;
}
if (newctrl & USB_CDC_SERIAL_STATE_BREAK) { if (newctrl & USB_CDC_SERIAL_STATE_BREAK) {
acm->iocount.brk++; acm->iocount.brk++;
tty_insert_flip_char(&acm->port, 0, TTY_BREAK); tty_insert_flip_char(&acm->port, 0, TTY_BREAK);