Skip to contentSkip to conversation

tty: always relink the port

PATCH In review Sudip Mukherjee 3 participants 3 messages Dec 27, 2019 – Jan 10, 2020 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: always relink the port

If the serial device is disconnected and reconnected, it re-enumerates properly but does not link it. fwiw, linking means just saving the port index, so allow it always as there is no harm in saving the same value again even if it tries to relink with the same port.

Fixes fb2b90014d78 ("tty: link tty and port before configuring it as console")
---
 drivers/tty/tty_port.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/tty_port.c +1 -2
index 5023c85ebc6e..044c3cbdcfa4 100644
@@ -89,8 +89,7 @@ void tty_port_link_device(struct tty_port *port,
 {
 	if (WARN_ON(index >= driver->num))
 		return;
-	if (!driver->ports[index])
-		driver->ports[index] = port;
+	driver->ports[index] = port;
 }
 EXPORT_SYMBOL_GPL(tty_port_link_device);
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 4 lines · Sudip Mukherjee

If the serial device is disconnected and reconnected, it re-enumerates properly but does not link it. fwiw, linking means just saving the port index, so allow it always as there is no harm in saving the same value again even if it tries to relink with the same port.

This is a pretty vague description. Commit fb2b90014d78 ("tty: link tty and port before configuring it as console") completely broke usb-serial (and anything else hotpluggable) which obviously depends on being able to reuse a minor number when a new device is later plugged in after a disconnect.

Things are crashing left and right due to that stale port-pointer, and I just had to debug this only to find that this one is sitting in the tty-linus branch. I know, I know, Christmas and all, but would be nice to get it into -rc6. :)

Quoted 1 line
Fixes fb2b90014d78 ("tty: link tty and port before configuring it as console")

Also note that the offending commit had a stable tag unlike this one.

Quoted 11 lines
---
 drivers/tty/tty_port.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/tty_port.c +0 -0
index 5023c85ebc6e..044c3cbdcfa4 100644

drivers/tty/tty_port.c void tty_port_link_device(struct tty_port *port, · line 94

Quoted 8 lines
drivers/tty/tty_port.c +1 -2
@@ -89,8 +89,7 @@ void tty_port_link_device(struct tty_port *port,
 {
 	if (WARN_ON(index >= driver->num))
 		return;
-	if (!driver->ports[index])
-		driver->ports[index] = port;
+	driver->ports[index] = port;
 }
 EXPORT_SYMBOL_GPL(tty_port_link_device);

Johan

#2 lore raw
Quoted 12 lines · Johan Hovold
Quoted 4 lines · Sudip Mukherjee

If the serial device is disconnected and reconnected, it re-enumerates properly but does not link it. fwiw, linking means just saving the port index, so allow it always as there is no harm in saving the same value again even if it tries to relink with the same port.

This is a pretty vague description. Commit fb2b90014d78 ("tty: link tty and port before configuring it as console") completely broke usb-serial (and anything else hotpluggable) which obviously depends on being able to reuse a minor number when a new device is later plugged in after a disconnect.

Quoted 4 lines

Things are crashing left and right due to that stale port-pointer, and I just had to debug this only to find that this one is sitting in the tty-linus branch. I know, I know, Christmas and all, but would be nice to get it into -rc6. :)

Sorry, yes, my fault, will get to Linus either today or tomorrow.

Quoted 3 lines
Quoted 1 line
Fixes fb2b90014d78 ("tty: link tty and port before configuring it as console")

Also note that the offending commit had a stable tag unlike this one.

I'll pick it up properly, I have held off on adding the original to the stable trees yet.

thanks,

greg k-h