usb: gadget: cdev: Fix spinlock recursion

Commit c99a841d40 ("usb: gadget: cdev: Add spinlock to synchronize
ports->cbits_updated")added spinlock to synchronize ports->cbits_updated
which is causing a spinlock recursion in usb_cser_notify_modem.

Fix this by unlocking the spinlock before it calls send_modem_ctrl_bits
which in turn tries to acquire the same spinlock.

Change-Id: I744ea93d7da60aaf27044400cf457cc81dab151d
Signed-off-by: Pratham Pratap <quic_ppratap@quicinc.com>
This commit is contained in:
Pratham Pratap 2023-07-19 11:56:18 +05:30
parent c99a841d40
commit fe41aca1e4

View File

@ -1679,6 +1679,7 @@ static void usb_cser_notify_modem(void *fport, int ctrl_bits)
spin_lock_irqsave(&port->port_lock, flags);
port->cbits_to_modem = temp;
port->cbits_updated = true;
spin_unlock_irqrestore(&port->port_lock, flags);
/* if DTR is high, update latest modem info to laptop */
if (port->cbits_to_modem & TIOCM_DTR) {
@ -1691,7 +1692,6 @@ static void usb_cser_notify_modem(void *fport, int ctrl_bits)
cser->send_modem_ctrl_bits(cser, cbits_to_laptop);
}
spin_unlock_irqrestore(&port->port_lock, flags);
wake_up(&port->read_wq);
}