aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2014-01-02 07:07:40 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-01-07 20:05:21 -0500
commitb8c98ae49e8d53344b1d62417eea05ebc3cdbd78 (patch)
treed50982086efec947214cc960d123afc616429dc9 /drivers
parent591cee0a35632031cd925392a1bce507dcfe9ea8 (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/pcmcia/synclink_cs.c4
-rw-r--r--drivers/tty/synclink.c4
-rw-r--r--drivers/tty/synclink_gt.c4
-rw-r--r--drivers/tty/synclinkmp.c4
4 files changed, 8 insertions, 8 deletions
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index d39cca659a3f..8320abd1ef14 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -2511,8 +2511,8 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
2511 2511
2512 /* If port is closing, signal caller to try again */ 2512 /* If port is closing, signal caller to try again */
2513 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){ 2513 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
2514 if (port->flags & ASYNC_CLOSING) 2514 wait_event_interruptible_tty(tty, port->close_wait,
2515 interruptible_sleep_on(&port->close_wait); 2515 !(port->flags & ASYNC_CLOSING));
2516 retval = ((port->flags & ASYNC_HUP_NOTIFY) ? 2516 retval = ((port->flags & ASYNC_HUP_NOTIFY) ?
2517 -EAGAIN : -ERESTARTSYS); 2517 -EAGAIN : -ERESTARTSYS);
2518 goto cleanup; 2518 goto cleanup;
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
index e1ce141bad5e..5ae14b46cce0 100644
--- a/drivers/tty/synclink.c
+++ b/drivers/tty/synclink.c
@@ -3404,8 +3404,8 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
3404 3404
3405 /* If port is closing, signal caller to try again */ 3405 /* If port is closing, signal caller to try again */
3406 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){ 3406 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
3407 if (info->port.flags & ASYNC_CLOSING) 3407 wait_event_interruptible_tty(tty, info->port.close_wait,
3408 interruptible_sleep_on(&info->port.close_wait); 3408 !(info->port.flags & ASYNC_CLOSING));
3409 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ? 3409 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
3410 -EAGAIN : -ERESTARTSYS); 3410 -EAGAIN : -ERESTARTSYS);
3411 goto cleanup; 3411 goto cleanup;
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 1abf946463f6..c359a91f7346 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -674,8 +674,8 @@ static int open(struct tty_struct *tty, struct file *filp)
674 674
675 /* If port is closing, signal caller to try again */ 675 /* If port is closing, signal caller to try again */
676 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){ 676 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
677 if (info->port.flags & ASYNC_CLOSING) 677 wait_event_interruptible_tty(tty, info->port.close_wait,
678 interruptible_sleep_on(&info->port.close_wait); 678 !(info->port.flags & ASYNC_CLOSING));
679 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ? 679 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
680 -EAGAIN : -ERESTARTSYS); 680 -EAGAIN : -ERESTARTSYS);
681 goto cleanup; 681 goto cleanup;
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
index dc6e96996ead..144202eef6fe 100644
--- a/drivers/tty/synclinkmp.c
+++ b/drivers/tty/synclinkmp.c
@@ -754,8 +754,8 @@ static int open(struct tty_struct *tty, struct file *filp)
754 754
755 /* If port is closing, signal caller to try again */ 755 /* If port is closing, signal caller to try again */
756 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){ 756 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
757 if (info->port.flags & ASYNC_CLOSING) 757 wait_event_interruptible_tty(tty, info->port.close_wait,
758 interruptible_sleep_on(&info->port.close_wait); 758 !(info->port.flags & ASYNC_CLOSING));
759 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ? 759 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
760 -EAGAIN : -ERESTARTSYS); 760 -EAGAIN : -ERESTARTSYS);
761 goto cleanup; 761 goto cleanup;