tty: synclink: avoid sleep_on race
The four variants of the synclink driver use the same code in their open() callback to wait for a port in process of being closed, using interruptible_sleep_on, which is racy and going away soon. Making things worse, these functions hold the BTM while doing so, which means that if we ever enter this code path, we cannot actually continue since the other thread that is in process of closing the port can no longer get the BTM. This addresses both issues by using wait_event_interruptible_tty() instead. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
591cee0a35
commit
b8c98ae49e
|
@ -2511,8 +2511,8 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
|
||||||
|
|
||||||
/* If port is closing, signal caller to try again */
|
/* If port is closing, signal caller to try again */
|
||||||
if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
|
if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
|
||||||
if (port->flags & ASYNC_CLOSING)
|
wait_event_interruptible_tty(tty, port->close_wait,
|
||||||
interruptible_sleep_on(&port->close_wait);
|
!(port->flags & ASYNC_CLOSING));
|
||||||
retval = ((port->flags & ASYNC_HUP_NOTIFY) ?
|
retval = ((port->flags & ASYNC_HUP_NOTIFY) ?
|
||||||
-EAGAIN : -ERESTARTSYS);
|
-EAGAIN : -ERESTARTSYS);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
|
@ -3404,8 +3404,8 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
|
||||||
|
|
||||||
/* If port is closing, signal caller to try again */
|
/* If port is closing, signal caller to try again */
|
||||||
if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
|
if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
|
||||||
if (info->port.flags & ASYNC_CLOSING)
|
wait_event_interruptible_tty(tty, info->port.close_wait,
|
||||||
interruptible_sleep_on(&info->port.close_wait);
|
!(info->port.flags & ASYNC_CLOSING));
|
||||||
retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
|
retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
|
||||||
-EAGAIN : -ERESTARTSYS);
|
-EAGAIN : -ERESTARTSYS);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
|
@ -674,8 +674,8 @@ static int open(struct tty_struct *tty, struct file *filp)
|
||||||
|
|
||||||
/* If port is closing, signal caller to try again */
|
/* If port is closing, signal caller to try again */
|
||||||
if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
|
if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
|
||||||
if (info->port.flags & ASYNC_CLOSING)
|
wait_event_interruptible_tty(tty, info->port.close_wait,
|
||||||
interruptible_sleep_on(&info->port.close_wait);
|
!(info->port.flags & ASYNC_CLOSING));
|
||||||
retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
|
retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
|
||||||
-EAGAIN : -ERESTARTSYS);
|
-EAGAIN : -ERESTARTSYS);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
|
@ -754,8 +754,8 @@ static int open(struct tty_struct *tty, struct file *filp)
|
||||||
|
|
||||||
/* If port is closing, signal caller to try again */
|
/* If port is closing, signal caller to try again */
|
||||||
if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
|
if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
|
||||||
if (info->port.flags & ASYNC_CLOSING)
|
wait_event_interruptible_tty(tty, info->port.close_wait,
|
||||||
interruptible_sleep_on(&info->port.close_wait);
|
!(info->port.flags & ASYNC_CLOSING));
|
||||||
retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
|
retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
|
||||||
-EAGAIN : -ERESTARTSYS);
|
-EAGAIN : -ERESTARTSYS);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
Loading…
Reference in New Issue