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 v3 3/5] hvcs: Get reference to tty in remove
Date: Fri, 3 Feb 2023 09:58:00 -0600 [thread overview]
Message-ID: <20230203155802.404324-4-brking@linux.vnet.ibm.com> (raw)
In-Reply-To: <20230203155802.404324-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 522910716025..8d40b20de277 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -799,7 +799,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);
@@ -814,8 +814,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-03 16:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-03 15:57 [PATCH v3 0/5] hvcs: Various hvcs device hotplug fixes Brian King
2023-02-03 15:57 ` [PATCH v3 1/5] hvcs: Use dev_groups to manage hvcs device attributes Brian King
2023-02-03 15:57 ` [PATCH v3 2/5] hvcs: Use driver groups to manage driver attributes Brian King
2023-02-03 15:58 ` Brian King [this message]
2023-02-03 15:58 ` [PATCH v3 4/5] hvcs: Use vhangup in hotplug remove Brian King
2023-02-03 15:58 ` [PATCH v3 5/5] 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=20230203155802.404324-4-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).