Commit a4ed2e73 authored by Peter Hurley's avatar Peter Hurley Committed by David S. Miller

net/irda: Fix port open counts

Saving the port count bump is unsafe. If the tty is hung up while
this open was blocking, the port count is zeroed.

Explicitly check if the tty was hung up while blocking, and correct
the port count if not.
Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0305d068
...@@ -280,7 +280,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, ...@@ -280,7 +280,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
struct tty_port *port = &self->port; struct tty_port *port = &self->port;
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
int retval; int retval;
int do_clocal = 0, extra_count = 0; int do_clocal = 0;
unsigned long flags; unsigned long flags;
IRDA_DEBUG(2, "%s()\n", __func__ ); IRDA_DEBUG(2, "%s()\n", __func__ );
...@@ -315,10 +315,8 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, ...@@ -315,10 +315,8 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
__FILE__, __LINE__, tty->driver->name, port->count); __FILE__, __LINE__, tty->driver->name, port->count);
spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp)) { if (!tty_hung_up_p(filp))
extra_count = 1;
port->count--; port->count--;
}
spin_unlock_irqrestore(&port->lock, flags); spin_unlock_irqrestore(&port->lock, flags);
port->blocked_open++; port->blocked_open++;
...@@ -361,12 +359,10 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, ...@@ -361,12 +359,10 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
remove_wait_queue(&port->open_wait, &wait); remove_wait_queue(&port->open_wait, &wait);
if (extra_count) {
/* ++ is not atomic, so this should be protected - Jean II */
spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp))
port->count++; port->count++;
spin_unlock_irqrestore(&port->lock, flags); spin_unlock_irqrestore(&port->lock, flags);
}
port->blocked_open--; port->blocked_open--;
IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n", IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment