Patch "tty: hvcs: Don't NULL tty->driver_data until hvcs_cleanup()" has been added to the 5.9-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    tty: hvcs: Don't NULL tty->driver_data until hvcs_cleanup()

to the 5.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     tty-hvcs-don-t-null-tty-driver_data-until-hvcs_clean.patch
and it can be found in the queue-5.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 6da30fded8f8c18fe9cfe0a493f69de1953b8acf
Author: Tyrel Datwyler <tyreld@xxxxxxxxxxxxx>
Date:   Thu Aug 20 18:46:38 2020 -0500

    tty: hvcs: Don't NULL tty->driver_data until hvcs_cleanup()
    
    [ Upstream commit 63ffcbdad738e3d1c857027789a2273df3337624 ]
    
    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: 27bf7c43a19c ("TTY: hvcs, add tty install")
    Signed-off-by: Tyrel Datwyler <tyreld@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20200820234643.70412-1-tyreld@xxxxxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index 55105ac38f89b..509d1042825a1 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -1216,13 +1216,6 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
 
 		tty_wait_until_sent(tty, HVCS_CLOSE_WAIT);
 
-		/*
-		 * This line is important because it tells hvcs_open that this
-		 * device needs to be re-configured the next time hvcs_open is
-		 * called.
-		 */
-		tty->driver_data = NULL;
-
 		free_irq(irq, hvcsd);
 		return;
 	} else if (hvcsd->port.count < 0) {
@@ -1237,6 +1230,13 @@ static void hvcs_cleanup(struct tty_struct * tty)
 {
 	struct hvcs_struct *hvcsd = tty->driver_data;
 
+	/*
+	 * This line is important because it tells hvcs_open that this
+	 * device needs to be re-configured the next time hvcs_open is
+	 * called.
+	 */
+	tty->driver_data = NULL;
+
 	tty_port_put(&hvcsd->port);
 }
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux