Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ad7c9af authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman
Browse files

Char: moxa, fix locking in moxa_write



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: default avatarJiri Slaby <jslaby@suse.cz>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7fdc2893
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -1202,14 +1202,15 @@ static int moxa_write(struct tty_struct *tty,
		      const unsigned char *buf, int count)
		      const unsigned char *buf, int count)
{
{
	struct moxa_port *ch = tty->driver_data;
	struct moxa_port *ch = tty->driver_data;
	unsigned long flags;
	int len;
	int len;


	if (ch == NULL)
	if (ch == NULL)
		return 0;
		return 0;


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


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