All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] can: sja1000: fix max irq loop handling
@ 2025-11-15 15:34 Thomas Mühlbacher
  2025-11-15 16:43 ` Oliver Hartkopp
  2025-11-16 15:25 ` Marc Kleine-Budde
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Mühlbacher @ 2025-11-15 15:34 UTC (permalink / raw)
  To: linux-can; +Cc: Marc Kleine-Budde, Vincent Mailhol, Thomas Mühlbacher

Reading the interrupt register `SJA1000_IR` causes all of its bits to be
reset. If we ever reach the condition of handling more than
`SJA1000_MAX_IRQ` IRQs, we will have read the register and reset all its
bits but without actually handling the interrupt inside of the loop
body.

This may, among other issues, cause us to never `netif_wake_queue()`
again after a transmission interrupt.

Fixes: 429da1cc841b ("can: Driver for the SJA1000 CAN controller")
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
---
 drivers/net/can/sja1000/sja1000.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index 4d245857ef1c..83476af8adb5 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -548,8 +548,8 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
 	if (priv->read_reg(priv, SJA1000_IER) == IRQ_OFF)
 		goto out;
 
-	while ((isrc = priv->read_reg(priv, SJA1000_IR)) &&
-	       (n < SJA1000_MAX_IRQ)) {
+	while ((n < SJA1000_MAX_IRQ) &&
+	       (isrc = priv->read_reg(priv, SJA1000_IR))) {
 
 		status = priv->read_reg(priv, SJA1000_SR);
 		/* check for absent controller due to hw unplug */
-- 
2.51.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-17 22:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-15 15:34 [PATCH] can: sja1000: fix max irq loop handling Thomas Mühlbacher
2025-11-15 16:43 ` Oliver Hartkopp
2025-11-16 15:25 ` Marc Kleine-Budde
2025-11-17 22:15   ` Thomas Mühlbacher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.