diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2014-06-16 09:17:06 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-07-10 19:06:49 -0400 |
commit | e359a4e38d229d53e28905863a1fabf41debd591 (patch) | |
tree | c70f7762dac31dad62188b7b8bb2140bea8b311a | |
parent | 5fda7a0e715c32c6dd9a39ebce8429eeafb64b7d (diff) |
tty: Remove tty_hung_up_p() tests from tty drivers' open()
Since at least before 2.6.30, it has not been possible to observe
a hung up file pointer in a tty driver's open() method unless/until
the driver open() releases the tty_lock() (eg., before blocking).
This is because tty_open() adds the file pointer while holding
the tty_lock() _and_ doesn't release the lock until after calling
the tty driver's open() method. [ Before tty_lock(), this was
lock_kernel(). ]
Since __tty_hangup() first waits on the tty_lock() before
enumerating and hanging up the open file pointers, either
__tty_hangup() will wait for the tty_lock() or tty_open() will
not yet have added the file pointer. For example,
CPU 0 | CPU 1
|
tty_open | __tty_hangup
.. | ..
tty_lock | ..
tty_reopen | tty_lock / blocks
.. |
tty_add_file(tty, filp) |
.. |
tty->ops->open(tty, filp) |
tty_port_open |
tty_port_block_til_ready |
.. |
while (1) |
.. |
tty_unlock | / unblocks
schedule | for each filp on tty->tty_files
| f_ops = tty_hung_up_fops;
| ..
| tty_unlock
tty_lock |
.. |
tty_unlock |
Note that since tty_port_block_til_ready() and similar drop
the tty_lock while blocking, when woken, the file pointer
must then be tested for having been hung up.
Also, fix bit-rotted drivers that used extra_count to track the
port->count bump.
CC: Mikael Starvik <starvik@axis.com>
CC: Samuel Ortiz <samuel@sortiz.org>
CC: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/char/pcmcia/synclink_cs.c | 2 | ||||
-rw-r--r-- | drivers/staging/dgrp/dgrp_tty.c | 10 | ||||
-rw-r--r-- | drivers/tty/cyclades.c | 2 | ||||
-rw-r--r-- | drivers/tty/serial/crisv10.c | 15 | ||||
-rw-r--r-- | drivers/tty/serial/serial_core.c | 8 | ||||
-rw-r--r-- | drivers/tty/synclink.c | 10 | ||||
-rw-r--r-- | drivers/tty/synclink_gt.c | 10 | ||||
-rw-r--r-- | drivers/tty/synclinkmp.c | 11 | ||||
-rw-r--r-- | drivers/tty/tty_port.c | 8 | ||||
-rw-r--r-- | net/irda/ircomm/ircomm_tty.c | 6 |
10 files changed, 21 insertions, 61 deletions
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 8320abd1ef14..a63970f76967 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -2510,7 +2510,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) | |||
2510 | __FILE__, __LINE__, tty->driver->name, port->count); | 2510 | __FILE__, __LINE__, tty->driver->name, port->count); |
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 (port->flags & ASYNC_CLOSING){ |
2514 | wait_event_interruptible_tty(tty, port->close_wait, | 2514 | wait_event_interruptible_tty(tty, port->close_wait, |
2515 | !(port->flags & ASYNC_CLOSING)); | 2515 | !(port->flags & ASYNC_CLOSING)); |
2516 | retval = ((port->flags & ASYNC_HUP_NOTIFY) ? | 2516 | retval = ((port->flags & ASYNC_HUP_NOTIFY) ? |
diff --git a/drivers/staging/dgrp/dgrp_tty.c b/drivers/staging/dgrp/dgrp_tty.c index 30d26029b21e..cdd1a69261dd 100644 --- a/drivers/staging/dgrp/dgrp_tty.c +++ b/drivers/staging/dgrp/dgrp_tty.c | |||
@@ -632,16 +632,6 @@ static int dgrp_tty_open(struct tty_struct *tty, struct file *file) | |||
632 | tty->driver_data = un; | 632 | tty->driver_data = un; |
633 | 633 | ||
634 | /* | 634 | /* |
635 | * If we are in the middle of hanging up, | ||
636 | * then return an error | ||
637 | */ | ||
638 | if (tty_hung_up_p(file)) { | ||
639 | retval = ((un->un_flag & UN_HUP_NOTIFY) ? | ||
640 | -EAGAIN : -ERESTARTSYS); | ||
641 | goto done; | ||
642 | } | ||
643 | |||
644 | /* | ||
645 | * If the port is in the middle of closing, then block | 635 | * If the port is in the middle of closing, then block |
646 | * until it is done, then try again. | 636 | * until it is done, then try again. |
647 | */ | 637 | */ |
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c index a57bb5ab761c..fd66f57390d0 100644 --- a/drivers/tty/cyclades.c +++ b/drivers/tty/cyclades.c | |||
@@ -1579,7 +1579,7 @@ static int cy_open(struct tty_struct *tty, struct file *filp) | |||
1579 | /* | 1579 | /* |
1580 | * If the port is the middle of closing, bail out now | 1580 | * If the port is the middle of closing, bail out now |
1581 | */ | 1581 | */ |
1582 | if (tty_hung_up_p(filp) || (info->port.flags & ASYNC_CLOSING)) { | 1582 | if (info->port.flags & ASYNC_CLOSING) { |
1583 | wait_event_interruptible_tty(tty, info->port.close_wait, | 1583 | wait_event_interruptible_tty(tty, info->port.close_wait, |
1584 | !(info->port.flags & ASYNC_CLOSING)); | 1584 | !(info->port.flags & ASYNC_CLOSING)); |
1585 | return (info->port.flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS; | 1585 | return (info->port.flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS; |
diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c index d567ac5d3af4..58e6f61a87e4 100644 --- a/drivers/tty/serial/crisv10.c +++ b/drivers/tty/serial/crisv10.c | |||
@@ -3831,14 +3831,13 @@ block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3831 | DECLARE_WAITQUEUE(wait, current); | 3831 | DECLARE_WAITQUEUE(wait, current); |
3832 | unsigned long flags; | 3832 | unsigned long flags; |
3833 | int retval; | 3833 | int retval; |
3834 | int do_clocal = 0, extra_count = 0; | 3834 | int do_clocal = 0; |
3835 | 3835 | ||
3836 | /* | 3836 | /* |
3837 | * If the device is in the middle of being closed, then block | 3837 | * If the device is in the middle of being closed, then block |
3838 | * until it's done, and then try again. | 3838 | * until it's done, and then try again. |
3839 | */ | 3839 | */ |
3840 | if (tty_hung_up_p(filp) || | 3840 | if (info->port.flags & ASYNC_CLOSING) { |
3841 | (info->port.flags & ASYNC_CLOSING)) { | ||
3842 | wait_event_interruptible_tty(tty, info->port.close_wait, | 3841 | wait_event_interruptible_tty(tty, info->port.close_wait, |
3843 | !(info->port.flags & ASYNC_CLOSING)); | 3842 | !(info->port.flags & ASYNC_CLOSING)); |
3844 | #ifdef SERIAL_DO_RESTART | 3843 | #ifdef SERIAL_DO_RESTART |
@@ -3879,10 +3878,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3879 | info->line, info->port.count); | 3878 | info->line, info->port.count); |
3880 | #endif | 3879 | #endif |
3881 | local_irq_save(flags); | 3880 | local_irq_save(flags); |
3882 | if (!tty_hung_up_p(filp)) { | 3881 | info->port.count--; |
3883 | extra_count++; | ||
3884 | info->port.count--; | ||
3885 | } | ||
3886 | local_irq_restore(flags); | 3882 | local_irq_restore(flags); |
3887 | info->port.blocked_open++; | 3883 | info->port.blocked_open++; |
3888 | while (1) { | 3884 | while (1) { |
@@ -3921,7 +3917,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3921 | } | 3917 | } |
3922 | set_current_state(TASK_RUNNING); | 3918 | set_current_state(TASK_RUNNING); |
3923 | remove_wait_queue(&info->port.open_wait, &wait); | 3919 | remove_wait_queue(&info->port.open_wait, &wait); |
3924 | if (extra_count) | 3920 | if (!tty_hung_up_p(filp)) |
3925 | info->port.count++; | 3921 | info->port.count++; |
3926 | info->port.blocked_open--; | 3922 | info->port.blocked_open--; |
3927 | #ifdef SERIAL_DEBUG_OPEN | 3923 | #ifdef SERIAL_DEBUG_OPEN |
@@ -3976,8 +3972,7 @@ rs_open(struct tty_struct *tty, struct file * filp) | |||
3976 | /* | 3972 | /* |
3977 | * If the port is in the middle of closing, bail out now | 3973 | * If the port is in the middle of closing, bail out now |
3978 | */ | 3974 | */ |
3979 | if (tty_hung_up_p(filp) || | 3975 | if (info->port.flags & ASYNC_CLOSING) { |
3980 | (info->port.flags & ASYNC_CLOSING)) { | ||
3981 | wait_event_interruptible_tty(tty, info->port.close_wait, | 3976 | wait_event_interruptible_tty(tty, info->port.close_wait, |
3982 | !(info->port.flags & ASYNC_CLOSING)); | 3977 | !(info->port.flags & ASYNC_CLOSING)); |
3983 | #ifdef SERIAL_DO_RESTART | 3978 | #ifdef SERIAL_DO_RESTART |
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 3e08df52d68d..1a5fbf7ab347 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c | |||
@@ -1584,14 +1584,6 @@ static int uart_open(struct tty_struct *tty, struct file *filp) | |||
1584 | tty_port_tty_set(port, tty); | 1584 | tty_port_tty_set(port, tty); |
1585 | 1585 | ||
1586 | /* | 1586 | /* |
1587 | * If the port is in the middle of closing, bail out now. | ||
1588 | */ | ||
1589 | if (tty_hung_up_p(filp)) { | ||
1590 | retval = -EAGAIN; | ||
1591 | goto err_dec_count; | ||
1592 | } | ||
1593 | |||
1594 | /* | ||
1595 | * Start up the serial port. | 1587 | * Start up the serial port. |
1596 | */ | 1588 | */ |
1597 | retval = uart_startup(tty, state, 0); | 1589 | retval = uart_startup(tty, state, 0); |
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c index d48e040cd8c5..b7991707ffc0 100644 --- a/drivers/tty/synclink.c +++ b/drivers/tty/synclink.c | |||
@@ -3267,7 +3267,6 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3267 | DECLARE_WAITQUEUE(wait, current); | 3267 | DECLARE_WAITQUEUE(wait, current); |
3268 | int retval; | 3268 | int retval; |
3269 | bool do_clocal = false; | 3269 | bool do_clocal = false; |
3270 | bool extra_count = false; | ||
3271 | unsigned long flags; | 3270 | unsigned long flags; |
3272 | int dcd; | 3271 | int dcd; |
3273 | struct tty_port *port = &info->port; | 3272 | struct tty_port *port = &info->port; |
@@ -3300,10 +3299,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3300 | __FILE__,__LINE__, tty->driver->name, port->count ); | 3299 | __FILE__,__LINE__, tty->driver->name, port->count ); |
3301 | 3300 | ||
3302 | spin_lock_irqsave(&info->irq_spinlock, flags); | 3301 | spin_lock_irqsave(&info->irq_spinlock, flags); |
3303 | if (!tty_hung_up_p(filp)) { | 3302 | port->count--; |
3304 | extra_count = true; | ||
3305 | port->count--; | ||
3306 | } | ||
3307 | spin_unlock_irqrestore(&info->irq_spinlock, flags); | 3303 | spin_unlock_irqrestore(&info->irq_spinlock, flags); |
3308 | port->blocked_open++; | 3304 | port->blocked_open++; |
3309 | 3305 | ||
@@ -3342,7 +3338,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3342 | remove_wait_queue(&port->open_wait, &wait); | 3338 | remove_wait_queue(&port->open_wait, &wait); |
3343 | 3339 | ||
3344 | /* FIXME: Racy on hangup during close wait */ | 3340 | /* FIXME: Racy on hangup during close wait */ |
3345 | if (extra_count) | 3341 | if (!tty_hung_up_p(filp)) |
3346 | port->count++; | 3342 | port->count++; |
3347 | port->blocked_open--; | 3343 | port->blocked_open--; |
3348 | 3344 | ||
@@ -3403,7 +3399,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp) | |||
3403 | __FILE__,__LINE__,tty->driver->name, info->port.count); | 3399 | __FILE__,__LINE__,tty->driver->name, info->port.count); |
3404 | 3400 | ||
3405 | /* If port is closing, signal caller to try again */ | 3401 | /* If port is closing, signal caller to try again */ |
3406 | if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){ | 3402 | if (info->port.flags & ASYNC_CLOSING){ |
3407 | wait_event_interruptible_tty(tty, info->port.close_wait, | 3403 | wait_event_interruptible_tty(tty, info->port.close_wait, |
3408 | !(info->port.flags & ASYNC_CLOSING)); | 3404 | !(info->port.flags & ASYNC_CLOSING)); |
3409 | retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ? | 3405 | retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ? |
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index c359a91f7346..ba1dbcdf4609 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c | |||
@@ -673,7 +673,7 @@ static int open(struct tty_struct *tty, struct file *filp) | |||
673 | DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count)); | 673 | DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count)); |
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 (info->port.flags & ASYNC_CLOSING){ |
677 | wait_event_interruptible_tty(tty, info->port.close_wait, | 677 | wait_event_interruptible_tty(tty, info->port.close_wait, |
678 | !(info->port.flags & ASYNC_CLOSING)); | 678 | !(info->port.flags & ASYNC_CLOSING)); |
679 | retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ? | 679 | retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ? |
@@ -3273,7 +3273,6 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3273 | DECLARE_WAITQUEUE(wait, current); | 3273 | DECLARE_WAITQUEUE(wait, current); |
3274 | int retval; | 3274 | int retval; |
3275 | bool do_clocal = false; | 3275 | bool do_clocal = false; |
3276 | bool extra_count = false; | ||
3277 | unsigned long flags; | 3276 | unsigned long flags; |
3278 | int cd; | 3277 | int cd; |
3279 | struct tty_port *port = &info->port; | 3278 | struct tty_port *port = &info->port; |
@@ -3300,10 +3299,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3300 | add_wait_queue(&port->open_wait, &wait); | 3299 | add_wait_queue(&port->open_wait, &wait); |
3301 | 3300 | ||
3302 | spin_lock_irqsave(&info->lock, flags); | 3301 | spin_lock_irqsave(&info->lock, flags); |
3303 | if (!tty_hung_up_p(filp)) { | 3302 | port->count--; |
3304 | extra_count = true; | ||
3305 | port->count--; | ||
3306 | } | ||
3307 | spin_unlock_irqrestore(&info->lock, flags); | 3303 | spin_unlock_irqrestore(&info->lock, flags); |
3308 | port->blocked_open++; | 3304 | port->blocked_open++; |
3309 | 3305 | ||
@@ -3338,7 +3334,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3338 | set_current_state(TASK_RUNNING); | 3334 | set_current_state(TASK_RUNNING); |
3339 | remove_wait_queue(&port->open_wait, &wait); | 3335 | remove_wait_queue(&port->open_wait, &wait); |
3340 | 3336 | ||
3341 | if (extra_count) | 3337 | if (!tty_hung_up_p(filp)) |
3342 | port->count++; | 3338 | port->count++; |
3343 | port->blocked_open--; | 3339 | port->blocked_open--; |
3344 | 3340 | ||
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c index 53ba8537de8d..c3f90910fed9 100644 --- a/drivers/tty/synclinkmp.c +++ b/drivers/tty/synclinkmp.c | |||
@@ -753,7 +753,7 @@ static int open(struct tty_struct *tty, struct file *filp) | |||
753 | __FILE__,__LINE__,tty->driver->name, info->port.count); | 753 | __FILE__,__LINE__,tty->driver->name, info->port.count); |
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 (info->port.flags & ASYNC_CLOSING){ |
757 | wait_event_interruptible_tty(tty, info->port.close_wait, | 757 | wait_event_interruptible_tty(tty, info->port.close_wait, |
758 | !(info->port.flags & ASYNC_CLOSING)); | 758 | !(info->port.flags & ASYNC_CLOSING)); |
759 | retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ? | 759 | retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ? |
@@ -3288,7 +3288,6 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3288 | DECLARE_WAITQUEUE(wait, current); | 3288 | DECLARE_WAITQUEUE(wait, current); |
3289 | int retval; | 3289 | int retval; |
3290 | bool do_clocal = false; | 3290 | bool do_clocal = false; |
3291 | bool extra_count = false; | ||
3292 | unsigned long flags; | 3291 | unsigned long flags; |
3293 | int cd; | 3292 | int cd; |
3294 | struct tty_port *port = &info->port; | 3293 | struct tty_port *port = &info->port; |
@@ -3322,10 +3321,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3322 | __FILE__,__LINE__, tty->driver->name, port->count ); | 3321 | __FILE__,__LINE__, tty->driver->name, port->count ); |
3323 | 3322 | ||
3324 | spin_lock_irqsave(&info->lock, flags); | 3323 | spin_lock_irqsave(&info->lock, flags); |
3325 | if (!tty_hung_up_p(filp)) { | 3324 | port->count--; |
3326 | extra_count = true; | ||
3327 | port->count--; | ||
3328 | } | ||
3329 | spin_unlock_irqrestore(&info->lock, flags); | 3325 | spin_unlock_irqrestore(&info->lock, flags); |
3330 | port->blocked_open++; | 3326 | port->blocked_open++; |
3331 | 3327 | ||
@@ -3362,8 +3358,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3362 | 3358 | ||
3363 | set_current_state(TASK_RUNNING); | 3359 | set_current_state(TASK_RUNNING); |
3364 | remove_wait_queue(&port->open_wait, &wait); | 3360 | remove_wait_queue(&port->open_wait, &wait); |
3365 | 3361 | if (!tty_hung_up_p(filp)) | |
3366 | if (extra_count) | ||
3367 | port->count++; | 3362 | port->count++; |
3368 | port->blocked_open--; | 3363 | port->blocked_open--; |
3369 | 3364 | ||
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c index 9209d6331b8e..1b9335796da4 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c | |||
@@ -365,7 +365,7 @@ int tty_port_block_til_ready(struct tty_port *port, | |||
365 | DEFINE_WAIT(wait); | 365 | DEFINE_WAIT(wait); |
366 | 366 | ||
367 | /* block if port is in the process of being closed */ | 367 | /* block if port is in the process of being closed */ |
368 | if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { | 368 | if (port->flags & ASYNC_CLOSING) { |
369 | wait_event_interruptible_tty(tty, port->close_wait, | 369 | wait_event_interruptible_tty(tty, port->close_wait, |
370 | !(port->flags & ASYNC_CLOSING)); | 370 | !(port->flags & ASYNC_CLOSING)); |
371 | if (port->flags & ASYNC_HUP_NOTIFY) | 371 | if (port->flags & ASYNC_HUP_NOTIFY) |
@@ -399,8 +399,7 @@ int tty_port_block_til_ready(struct tty_port *port, | |||
399 | 399 | ||
400 | /* The port lock protects the port counts */ | 400 | /* The port lock protects the port counts */ |
401 | spin_lock_irqsave(&port->lock, flags); | 401 | spin_lock_irqsave(&port->lock, flags); |
402 | if (!tty_hung_up_p(filp)) | 402 | port->count--; |
403 | port->count--; | ||
404 | port->blocked_open++; | 403 | port->blocked_open++; |
405 | spin_unlock_irqrestore(&port->lock, flags); | 404 | spin_unlock_irqrestore(&port->lock, flags); |
406 | 405 | ||
@@ -593,8 +592,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty, | |||
593 | struct file *filp) | 592 | struct file *filp) |
594 | { | 593 | { |
595 | spin_lock_irq(&port->lock); | 594 | spin_lock_irq(&port->lock); |
596 | if (!tty_hung_up_p(filp)) | 595 | ++port->count; |
597 | ++port->count; | ||
598 | spin_unlock_irq(&port->lock); | 596 | spin_unlock_irq(&port->lock); |
599 | tty_port_tty_set(port, tty); | 597 | tty_port_tty_set(port, tty); |
600 | 598 | ||
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index 2ba8b9705bb7..61ceb4cdb4a2 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c | |||
@@ -320,8 +320,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, | |||
320 | __FILE__, __LINE__, tty->driver->name, port->count); | 320 | __FILE__, __LINE__, tty->driver->name, port->count); |
321 | 321 | ||
322 | spin_lock_irqsave(&port->lock, flags); | 322 | spin_lock_irqsave(&port->lock, flags); |
323 | if (!tty_hung_up_p(filp)) | 323 | port->count--; |
324 | port->count--; | ||
325 | port->blocked_open++; | 324 | port->blocked_open++; |
326 | spin_unlock_irqrestore(&port->lock, flags); | 325 | spin_unlock_irqrestore(&port->lock, flags); |
327 | 326 | ||
@@ -458,8 +457,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp) | |||
458 | /* | 457 | /* |
459 | * If the port is the middle of closing, bail out now | 458 | * If the port is the middle of closing, bail out now |
460 | */ | 459 | */ |
461 | if (tty_hung_up_p(filp) || | 460 | if (test_bit(ASYNCB_CLOSING, &self->port.flags)) { |
462 | test_bit(ASYNCB_CLOSING, &self->port.flags)) { | ||
463 | 461 | ||
464 | /* Hm, why are we blocking on ASYNC_CLOSING if we | 462 | /* Hm, why are we blocking on ASYNC_CLOSING if we |
465 | * do return -EAGAIN/-ERESTARTSYS below anyway? | 463 | * do return -EAGAIN/-ERESTARTSYS below anyway? |