diff options
author | Brian King <brking@linux.vnet.ibm.com> | 2023-02-03 18:58:00 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-02-08 15:09:15 +0300 |
commit | 3a8d3b366ce47024bf274eac783f8af5df2780f5 (patch) | |
tree | e77897467377b0eb1adc0bdb655ad10a5365b3fd /drivers/tty | |
parent | 503a90dd619d52dcac2cc68bd742aa914c7cd47a (diff) | |
download | linux-3a8d3b366ce47024bf274eac783f8af5df2780f5.tar.xz |
hvcs: Get reference to tty in remove
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>
Link: https://lore.kernel.org/r/20230203155802.404324-4-brking@linux.vnet.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/hvc/hvcs.c | 6 |
1 files 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); |