linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Brian King <brking@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Brian King <brking@linux.vnet.ibm.com>,
	mmc@linux.vnet.ibm.com, brking@pobox.com
Subject: [PATCH 4/7] hvcs: Get reference to tty in remove
Date: Mon, 30 Jan 2023 16:43:18 -0600	[thread overview]
Message-ID: <20230130224321.164843-5-brking@linux.vnet.ibm.com> (raw)
In-Reply-To: <20230130224321.164843-1-brking@linux.vnet.ibm.com>

Grab a reference to the tty when removing the hvcs to ensure
it does not get freed unexpectedly.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---
 drivers/tty/hvc/hvcs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index 9c5887d0c882..b28ddfc46e42 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -802,7 +802,7 @@ static void hvcs_remove(struct vio_dev *dev)
 
 	spin_lock_irqsave(&hvcsd->lock, flags);
 
-	tty = hvcsd->port.tty;
+	tty = tty_port_tty_get(&hvcsd->port);
 
 	spin_unlock_irqrestore(&hvcsd->lock, flags);
 
@@ -819,8 +819,10 @@ static void hvcs_remove(struct vio_dev *dev)
 	 * hvcs_hangup.  The tty should always be valid at this time unless a
 	 * simultaneous tty close already cleaned up the hvcs_struct.
 	 */
-	if (tty)
+	if (tty) {
 		tty_hangup(tty);
+		tty_kref_put(tty);
+	}
 
 	printk(KERN_INFO "HVCS: vty-server@%X removed from the"
 			" vio bus.\n", dev->unit_address);
-- 
2.31.1


  parent reply	other threads:[~2023-01-30 22:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-30 22:43 [PATCH 0/7] hvcs: Various hvcs device hotplug fixes Brian King
2023-01-30 22:43 ` [PATCH 1/7] hvcs: Fix hvcs port reference counting Brian King
2023-01-30 22:43 ` [PATCH 2/7] hvcs: Remove sysfs file prior to vio unregister Brian King
2023-01-30 22:43 ` [PATCH 3/7] hvcs: Remove sysfs group earlier Brian King
2023-01-30 22:43 ` Brian King [this message]
2023-01-30 22:43 ` [PATCH 5/7] hvcs: Use vhangup in hotplug remove Brian King
2023-01-30 22:43 ` [PATCH 6/7] hvcs: Synchronize hotplug remove with port free Brian King
2023-01-30 22:43 ` [PATCH 7/7] powerpc: Fix device node refcounting Brian King
2023-02-01 10:32 ` [PATCH 0/7] hvcs: Various hvcs device hotplug fixes Christophe Leroy
2023-02-01 15:09   ` Brian King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230130224321.164843-5-brking@linux.vnet.ibm.com \
    --to=brking@linux.vnet.ibm.com \
    --cc=brking@pobox.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mmc@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).