[091/119] tty_port: handle the nonblocking open of a dead port corner case

Greg KH
2009-12-07T00:14:13Z

[-- Attachment #1: tty_port-handle-the-nonblocking-open-of-a-dead-port-corner-case.patch --]
[-- Type: text/plain, Size: 1092 bytes --]

2.6.31-stable review patch. If anyone has any objections, please let us know.

------------------
From: Alan Cox <alan@linux.intel.com>

commit 8627b96dd80dca440d91fbb1ec733be25912d0dd upstream.

Some drivers allow O_NDELAY of a dead port (eg for setserial to work). In that
situation we must not try to raise the carrier.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
drivers/char/tty_port.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

--- a/drivers/char/tty_port.c
+++ b/drivers/char/tty_port.c
@@ -217,8 +217,11 @@ int tty_port_block_til_ready(struct tty_

/* if non-blocking mode is set we can pass directly to open unless
the port has just hung up or is in another error state */
- if ((filp->f_flags & O_NONBLOCK) ||
- (tty->flags & (1 << TTY_IO_ERROR))) {
+ if (tty->flags & (1 << TTY_IO_ERROR)) {
+ port->flags |= ASYNC_NORMAL_ACTIVE;
+ return 0;
+ }
+ if (filp->f_flags & O_NONBLOCK) {
/* Indicate we are open */
if (tty->termios->c_cflag & CBAUD)
tty_port_raise_dtr_rts(port);