mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] can: softing: lock card->fw.lock unconditionally in softing_card_shutdown()
@ 2026-11-19 17:07 Ian Rogers
  2026-11-19 17:26 ` Oliver Hartkopp
  2026-11-19 17:27 ` Marc Kleine-Budde
  0 siblings, 2 replies; 3+ messages in thread
From: Ian Rogers @ 2026-11-19 17:07 UTC (permalink / raw)
  To: Marc Kleine-Budde, Vincent Mailhol
  Cc: linux-can, linux-kernel, llvm, Elkin Cruz, Ian Rogers

softing_card_shutdown() calls mutex_lock_interruptible(&card->fw.lock)
with an empty if-body ('{ /* return -ERESTARTSYS */; }'). Because
softing_pdev_remove() invokes softing_card_shutdown() before
unregistering netdevs or removing sysfs attributes, a pending signal
while card->fw.lock is contended causes mutex_lock_interruptible() to
return -EINTR without acquiring the lock. Execution then proceeds unlocked
through IRQ and DPRAM teardown and calls mutex_unlock(&card->fw.lock) on a
mutex not owned by the current task.

Use mutex_lock(&card->fw.lock) in softing_card_shutdown().

Found via an x86_64 LLVM=1 (Clang 21.1.8) allyesconfig audit with
-Wextra-semi-stmt enabled; fix and changelog drafted with an AI coding
assistant. Build-tested under LLVM=1 W=1 (-Werror) and -Wextra-semi-stmt;
not tested on Softing CAN hardware.

Fixes: 03fd3cf5a179 ("can: add driver for Softing card")
Fixes: 47fa0336c1b7 ("can: softing: softing_card_shutdown(): add  braces around empty body in an 'if' statement")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 drivers/net/can/softing/softing_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/can/softing/softing_main.c b/drivers/net/can/softing/softing_main.c
index 519ab3097f86..d3dfad4f5321 100644
--- a/drivers/net/can/softing/softing_main.c
+++ b/drivers/net/can/softing/softing_main.c
@@ -448,9 +448,7 @@ static void softing_card_shutdown(struct softing *card)
 {
 	int fw_up = 0;
 
-	if (mutex_lock_interruptible(&card->fw.lock)) {
-		/* return -ERESTARTSYS */;
-	}
+	mutex_lock(&card->fw.lock);
 	fw_up = card->fw.up;
 	card->fw.up = 0;
 
-- 
2.56.1.708.g77570a6a1d-goog


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

end of thread, other threads:[~2026-11-19 17:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 17:07 [PATCH] can: softing: lock card->fw.lock unconditionally in softing_card_shutdown() Ian Rogers
2026-11-19 17:26 ` Oliver Hartkopp
2026-11-19 17:27 ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®