Skip to contentSkip to conversation

usb: gadget: u_serial: remove some dead code

PATCH In review Dan Carpenter 2 participants 3 messages Jun 25, 2025 – Jun 26, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: gadget: u_serial: remove some dead code

There is no need to check if "port" is NULL. We already verified that it is non-NULL. It's a stack variable and can't be modified by a different thread. Delete this dead code.

---
 drivers/usb/gadget/function/u_serial.c | 7 ------
 1 file changed, 6 deletions(-)
drivers/usb/gadget/function/u_serial.c +0 -6
index ab544f6824be..96756a489d6a 100644
@@ -1501,13 +1501,7 @@ 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);
Signature · 1 line
2.47.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dan Carpenter

There is no need to check if "port" is NULL. We already verified that it is non-NULL. It's a stack variable and can't be modified by a different thread. Delete this dead code.

---

Perhaps you could add Closes and Fixes tag, but its up to you.

Quoted 21 lines
 drivers/usb/gadget/function/u_serial.c | 7 ------
 1 file changed, 6 deletions(-)
drivers/usb/gadget/function/u_serial.c +0 -6
index ab544f6824be..96756a489d6a 100644
@@ -1501,13 +1501,7 @@ 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);
#2 lore raw
Quoted 11 lines · Prashanth K
Quoted 6 lines · Dan Carpenter

There is no need to check if "port" is NULL. We already verified that it is non-NULL. It's a stack variable and can't be modified by a different thread. Delete this dead code.

---

Perhaps you could add Closes and Fixes tag, but its up to you.

Fixes is only for bugs. If I put a Closes tag, then I'd have to give myself reported by credit as well which is just being greedy for tags. :P

regards,
dan carpenter