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

Commit 367525c8 authored by Alexander Stein's avatar Alexander Stein Committed by Marc Kleine-Budde
Browse files

can: slcan: Fix spinlock variant



slc_xmit is called within softirq context and locks sl->lock, but
slcan_write_wakeup is not softirq context, so we need to use
spin_[un]lock_bh!
Detected using kernel lock debugging mechanism.

Signed-off-by: default avatarAlexander Stein <alexander.stein@systec-electronic.com>
Acked-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent d4824432
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -322,13 +322,13 @@ static void slcan_write_wakeup(struct tty_struct *tty)
	if (!sl || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev))
		return;

	spin_lock(&sl->lock);
	spin_lock_bh(&sl->lock);
	if (sl->xleft <= 0)  {
		/* Now serial buffer is almost free & we can start
		 * transmission of another packet */
		sl->dev->stats.tx_packets++;
		clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
		spin_unlock(&sl->lock);
		spin_unlock_bh(&sl->lock);
		netif_wake_queue(sl->dev);
		return;
	}
@@ -336,7 +336,7 @@ static void slcan_write_wakeup(struct tty_struct *tty)
	actual = tty->ops->write(tty, sl->xhead, sl->xleft);
	sl->xleft -= actual;
	sl->xhead += actual;
	spin_unlock(&sl->lock);
	spin_unlock_bh(&sl->lock);
}

/* Send a can_frame to a TTY queue. */