Skip to content

Commit

Permalink
Char: moxa, fix locking in moxa_write
Browse files Browse the repository at this point in the history
moxa_write can be called from atomic context with irqs disabled (from
ppp_async_push). Don't enable interrupts by spin_unlock_bh as this
might cause deadlocks in the ppp layer.

Instead, use irqsave/irqrestore spin_lock functions.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jiri Slaby authored and Greg Kroah-Hartman committed Apr 25, 2011
1 parent 7fdc289 commit 0ad7c9a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/tty/moxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1202,14 +1202,15 @@ static int moxa_write(struct tty_struct *tty,
const unsigned char *buf, int count)
{
struct moxa_port *ch = tty->driver_data;
unsigned long flags;
int len;

if (ch == NULL)
return 0;

spin_lock_bh(&moxa_lock);
spin_lock_irqsave(&moxa_lock, flags);
len = MoxaPortWriteData(tty, buf, count);
spin_unlock_bh(&moxa_lock);
spin_unlock_irqrestore(&moxa_lock, flags);

set_bit(LOWWAIT, &ch->statusflags);
return len;
Expand Down

0 comments on commit 0ad7c9a

Please sign in to comment.