浏览代码

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>
Johan Hovold 7 年之前
父节点
当前提交
90dbad8cd6
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      drivers/tty/serdev/serdev-ttyport.c

+ 2 - 0
drivers/tty/serdev/serdev-ttyport.c

@@ -154,8 +154,10 @@ static void ttyport_close(struct serdev_controller *ctrl)
 
 
 	clear_bit(SERPORT_ACTIVE, &serport->flags);
 	clear_bit(SERPORT_ACTIVE, &serport->flags);
 
 
+	tty_lock(tty);
 	if (tty->ops->close)
 	if (tty->ops->close)
 		tty->ops->close(tty, NULL);
 		tty->ops->close(tty, NULL);
+	tty_unlock(tty);
 
 
 	tty_release_struct(tty, serport->tty_idx);
 	tty_release_struct(tty, serport->tty_idx);
 }
 }