Skip to content

Commit 8f68d61

Browse files
tyreldgregkh
authored andcommitted
tty: hvcs: Don't NULL tty->driver_data until hvcs_cleanup()
[ Upstream commit 63ffcbd ] The code currently NULLs tty->driver_data in hvcs_close() with the intent of informing the next call to hvcs_open() that device needs to be reconfigured. However, when hvcs_cleanup() is called we copy hvcsd from tty->driver_data which was previoulsy NULLed by hvcs_close() and our call to tty_port_put(&hvcsd->port) doesn't actually do anything since &hvcsd->port ends up translating to NULL by chance. This has the side effect that when hvcs_remove() is called we have one too many port references preventing hvcs_destuct_port() from ever being called. This also prevents us from reusing the /dev/hvcsX node in a future hvcs_probe() and we can eventually run out of /dev/hvcsX devices. Fix this by waiting to NULL tty->driver_data in hvcs_cleanup(). Fixes: 27bf7c4 ("TTY: hvcs, add tty install") Signed-off-by: Tyrel Datwyler <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 864d8f4 commit 8f68d61

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/tty/hvc/hvcs.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,13 +1216,6 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
12161216

12171217
tty_wait_until_sent(tty, HVCS_CLOSE_WAIT);
12181218

1219-
/*
1220-
* This line is important because it tells hvcs_open that this
1221-
* device needs to be re-configured the next time hvcs_open is
1222-
* called.
1223-
*/
1224-
tty->driver_data = NULL;
1225-
12261219
free_irq(irq, hvcsd);
12271220
return;
12281221
} else if (hvcsd->port.count < 0) {
@@ -1237,6 +1230,13 @@ static void hvcs_cleanup(struct tty_struct * tty)
12371230
{
12381231
struct hvcs_struct *hvcsd = tty->driver_data;
12391232

1233+
/*
1234+
* This line is important because it tells hvcs_open that this
1235+
* device needs to be re-configured the next time hvcs_open is
1236+
* called.
1237+
*/
1238+
tty->driver_data = NULL;
1239+
12401240
tty_port_put(&hvcsd->port);
12411241
}
12421242

0 commit comments

Comments
 (0)