summaryrefslogtreecommitdiff
path: root/drivers/tty
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-11-03 17:30:56 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-11-28 18:00:50 +0300
commit90dbad8cd6efccbdce109d5ef0724f8434a6cdde (patch)
tree4d4bd460a12938f02c3811714352da6876594f8a /drivers/tty
parent8bcd4e6a8decac251d55c4377e2e67f052777ce0 (diff)
downloadlinux-90dbad8cd6efccbdce109d5ef0724f8434a6cdde.tar.xz
serdev: ttyport: fix tty locking in close
Make sure to hold the tty lock as required when calling tty-driver close() (e.g. to avoid racing with hangup()). Note that the serport active flag is currently set under the lock at controller open, but really isn't protected by it. Fixes: cd6484e1830b ("serdev: Introduce new bus for serial attached devices") Signed-off-by: Johan Hovold <johan@kernel.org> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serdev/serdev-ttyport.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c
index 12cb9139073e..247788a16f0b 100644
--- a/drivers/tty/serdev/serdev-ttyport.c
+++ b/drivers/tty/serdev/serdev-ttyport.c
@@ -154,8 +154,10 @@ static void ttyport_close(struct serdev_controller *ctrl)
clear_bit(SERPORT_ACTIVE, &serport->flags);
+ tty_lock(tty);
if (tty->ops->close)
tty->ops->close(tty, NULL);
+ tty_unlock(tty);
tty_release_struct(tty, serport->tty_idx);
}