From: Brian King <brking@linux.vnet.ibm.com>
To: gregkh@linuxfoundation.org
Cc: Brian King <brking@linux.vnet.ibm.com>,
mmc@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org,
linux-serial@vger.kernel.org, brking@pobox.com
Subject: [PATCH v2 4/6] hvcs: Get reference to tty in remove
Date: Thu, 2 Feb 2023 16:28:02 -0600 [thread overview]
Message-ID: <20230202222804.383229-5-brking@linux.vnet.ibm.com> (raw)
In-Reply-To: <20230202222804.383229-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 5de7ad555540..04c58ac4fec2 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -813,7 +813,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);
@@ -828,8 +828,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
next prev parent reply other threads:[~2023-02-02 22:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 22:27 [PATCH v2 0/6] hvcs: Various hvcs device hotplug fixes Brian King
2023-02-02 22:27 ` [PATCH v2 1/6] hvcs: Fix hvcs port reference counting Brian King
2023-02-03 5:10 ` Greg KH
2023-02-02 22:28 ` [PATCH v2 2/6] hvcs: Use dev_groups to manage hvcs device attributes Brian King
2023-02-03 5:10 ` Greg KH
2023-02-02 22:28 ` [PATCH v2 3/6] hvcs: Use driver groups to manage driver attributes Brian King
2023-02-03 5:11 ` Greg KH
2023-02-02 22:28 ` Brian King [this message]
2023-02-02 22:28 ` [PATCH v2 5/6] hvcs: Use vhangup in hotplug remove Brian King
2023-02-02 22:28 ` [PATCH v2 6/6] hvcs: Synchronize hotplug remove with port free 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=20230202222804.383229-5-brking@linux.vnet.ibm.com \
--to=brking@linux.vnet.ibm.com \
--cc=brking@pobox.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-serial@vger.kernel.org \
--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).