mirror of
https://github.com/torvalds/linux.git
synced 2026-03-13 23:46:14 +01:00
usb: gadget: u_serial: Avoid double unlock of serial_port_lock
Avoid unlocking serial_port_lock twice in gserial_suspend(), this can
occur if gserial_wakeup_host() fails. And since wakeup is performed
outside spinlock, check if the port is valid before proceeding again.
Fixes: 3baea29dc0 ("usb: gadget: u_serial: Implement remote wakeup capability")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/aBHatifO5bjR1yPt@stanley.mountain/
Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250506104912.3750934-1-prashanth.k@oss.qualcomm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
a541acceed
commit
1c06aff9b8
1 changed files with 7 additions and 0 deletions
|
|
@ -1505,6 +1505,13 @@ void gserial_suspend(struct gserial *gser)
|
|||
spin_unlock_irqrestore(&serial_port_lock, flags);
|
||||
if (!gserial_wakeup_host(gser))
|
||||
return;
|
||||
|
||||
/* Check if port is valid after acquiring lock back */
|
||||
spin_lock_irqsave(&serial_port_lock, flags);
|
||||
if (!port) {
|
||||
spin_unlock_irqrestore(&serial_port_lock, flags);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
spin_lock(&port->port_lock);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue