Skip to content

Commit 8d5f31e

Browse files
author
Desnes Nunes
committed
usb: gadget: u_serial: Avoid double unlock of serial_port_lock
JIRA: https://issues.redhat.com/browse/RHEL-116016 commit 1c06aff Author: Prashanth K <prashanth.k@oss.qualcomm.com> Date: Tue, 6 May 2025 16:19:12 +0530 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> Signed-off-by: Desnes Nunes <desnesn@redhat.com>
1 parent fe15d99 commit 8d5f31e

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
@@ -1475,6 +1475,13 @@ void gserial_suspend(struct gserial *gser)
14751475
spin_unlock_irqrestore(&serial_port_lock, flags);
14761476
if (!gserial_wakeup_host(gser))
14771477
return;
1478+
1479+
/* Check if port is valid after acquiring lock back */
1480+
spin_lock_irqsave(&serial_port_lock, flags);
1481+
if (!port) {
1482+
spin_unlock_irqrestore(&serial_port_lock, flags);
1483+
return;
1484+
}
14781485
}
14791486

14801487
spin_lock(&port->port_lock);

0 commit comments

Comments
 (0)