[PATCH 6/6] firewire: core: narrow the card lock scope when accessing node_id
From: Takashi Sakamoto
Date: Thu Oct 08 2026 - 19:46:19 EST
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.
Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx>
---
drivers/firewire/core-transaction.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index 7d512defdeb3..4da4686fb28c 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -439,11 +439,12 @@ __must_not_hold(&card->transactions.lock)
timer_setup(&t->split_timeout_timer, split_transaction_timeout_callback, 0);
t->packet.callback = transmit_complete_callback;
- 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);
- }
+ // The node_id field of fw_card can be updated when handling SelfIDComplete.
+ int node_id;
+ 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);
scoped_guard(spinlock_irqsave, &card->transactions.lock)
list_add_tail(&t->link, &card->transactions.list);
--
2.53.0