Skip to content

Commit 1c06aff

Browse files
Prashanth Kgregkh
authored andcommitted
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: 3baea29 ("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>
1 parent a541acc commit 1c06aff

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/usb/gadget/function/u_serial.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,13 @@ void gserial_suspend(struct gserial *gser)
15051505
spin_unlock_irqrestore(&serial_port_lock, flags);
15061506
if (!gserial_wakeup_host(gser))
15071507
return;
1508+
1509+
/* Check if port is valid after acquiring lock back */
1510+
spin_lock_irqsave(&serial_port_lock, flags);
1511+
if (!port) {
1512+
spin_unlock_irqrestore(&serial_port_lock, flags);
1513+
return;
1514+
}
15081515
}
15091516

15101517
spin_lock(&port->port_lock);

0 commit comments

Comments
 (0)