usb: gadget: cdev: Don't use spinlock with sleeping functions

Commit c99a841d40 ("usb: gadget: cdev: Add spinlock to synchronize
ports->cbits_updated")added spinlock to synchronize ports->cbits_updated
which is calling a sleeping function(put_user) after spinlock is held.

Fix this by protecting just variable, ports->cbits_updated.

Change-Id: I0a52a88344c449c9485f41b871cc97e54b4bf3ca
Signed-off-by: Pratham Pratap <quic_ppratap@quicinc.com>
This commit is contained in:
Pratham Pratap 2023-08-07 12:01:01 +05:30
parent d38d8bb8ff
commit 02923fa81a

View File

@ -1639,13 +1639,13 @@ static long f_cdev_ioctl(struct file *fp, unsigned int cmd,
break;
case TIOCMGET:
pr_debug("TIOCMGET on port(%s)%pK\n", port->name, port);
spin_lock_irqsave(&port->port_lock, flags);
ret = f_cdev_tiocmget(port);
if (ret >= 0) {
ret = put_user(ret, (uint32_t *)arg);
spin_lock_irqsave(&port->port_lock, flags);
port->cbits_updated = false;
spin_unlock_irqrestore(&port->port_lock, flags);
}
spin_unlock_irqrestore(&port->port_lock, flags);
break;
default:
pr_err("Received cmd:%d not supported\n", cmd);