mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] firewire: ohci: avoid potential deadlock when queueing AT local requests
@ 2026-11-02  3:30 Takashi Sakamoto
  2026-11-03  3:56 ` Takashi Sakamoto
  0 siblings, 1 reply; 2+ messages in thread
From: Takashi Sakamoto @ 2026-11-02  3:30 UTC (permalink / raw)
  To: linux1394-devel; +Cc: linux-kernel

AT local requests are retrieved from the queue in process context
(workqueue), while requests can be added to the queue from any context
through __fw_send_request(). The queue is protected by a spinlock, but
interrupts are still enabled when acquiring the lock in the former case.

This can lead to a deadlock if the same lock is acquired from interrupt
context while it is already held.

Avoid the deadlock by using a pair of spin_lock_irqsave() and
spin_unlock_irqrestore() to protect access to the queue.

Fixes: 5fe52c6aa28e ("firewire: ohci: use workqueue to handle error case of AT request/response packet queueing")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 drivers/firewire/ohci.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index c06e8d87239c..cf49910fa900 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -1593,12 +1593,13 @@ static void handle_at_local_packets(struct at_local *local, struct fw_ohci *ohci
 			void (*handle_at_local_packet)(struct fw_ohci *, struct fw_packet *))
 {
 	struct fw_packet *packet;
+	unsigned long flags;
 
-	spin_lock(&local->lock);
+	spin_lock_irqsave(&local->lock, flags);
 
 	while ((packet = list_first_entry_or_null(&local->list, typeof(*packet), link_for_local))) {
 		list_del_init(&packet->link_for_local);
-		spin_unlock(&local->lock);
+		spin_unlock_irqrestore(&local->lock, flags);
 
 		if (unlikely(packet->ack != 0)) {
 			// This case is active when the call of at_context_queue_packet() returns
@@ -1608,10 +1609,10 @@ static void handle_at_local_packets(struct at_local *local, struct fw_ohci *ohci
 			handle_at_local_packet(ohci, packet);
 		}
 
-		spin_lock(&local->lock);
+		spin_lock_irqsave(&local->lock, flags);
 	}
 
-	spin_unlock(&local->lock);
+	spin_unlock_irqrestore(&local->lock, flags);
 }
 
 static void at_request_local_work(struct work_struct *work)

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
-- 
2.53.0


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

end of thread, other threads:[~2026-11-03  3:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-02  3:30 [PATCH] firewire: ohci: avoid potential deadlock when queueing AT local requests Takashi Sakamoto
2026-11-03  3:56 ` Takashi Sakamoto

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®