From aea8c084cb93fb250f096143bf038855405456c9 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sun, 11 Oct 2026 15:31:46 +0900 Subject: [PATCH] firewire: core: narrow the card lock scope when accessing node_id When preparing the request subaction for an asynchronous transaction, the node_id field in the fw_card structure is accessed under the card-level spinlock. However, the lock is held across a call to a helper function, unnecessarily extending the critical section. Narrow the critical section to cover only the access to node_id. Link: https://lore.kernel.org/r/20261011063146.497455-7-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-transaction.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c index ee1679347b36..97be9fddadcb 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c @@ -455,13 +455,15 @@ __must_not_hold(&card->transactions.lock) timer_setup(&t->split_timeout_timer, split_transaction_timeout_callback, 0); t->packet.callback = transmit_complete_callback; + // The node_id field of fw_card can be updated when handling SelfIDComplete. + int node_id; + // NOTE: This can be without irqsave when we can guarantee that __fw_send_request() for // local destination never runs in any type of IRQ context. - scoped_guard(spinlock_irqsave, &card->lock) { - // The node_id field of fw_card can be updated when handling SelfIDComplete. - fw_fill_request(&t->packet, tcode, t->tlabel, destination_id, card->node_id, - generation, speed, offset, payload, length); - } + scoped_guard(spinlock_irqsave, &card->lock) + node_id = card->node_id; + fw_fill_request(&t->packet, tcode, t->tlabel, destination_id, node_id, generation, speed, + offset, payload, length); // NOTE: This can be without irqsave when we can guarantee that __fw_send_request() for // local destination never runs in any type of IRQ context.