[PATCH 1/9] firewire: core: add context analysis annotations for address handler

From: Takashi Sakamoto

Date: Sun Nov 01 2026 - 23:20:35 EST


The address handler list is protected by a spinlock when handlers are
added to or removed from the list, while readers traverse the list within
RCU read-side critical sections.

Use both the spinlock and RCU read-side lock annotations to describe the
synchronization requirements for accessing the list. This allows
compiler-based context analysis to verify that the list is accessed under
the appropriate synchronization context.

Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx>
---
drivers/firewire/core-transaction.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index 0ebe70a4d440..8d7e0f03aa6a 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -590,12 +590,18 @@ void fw_send_phy_config(struct fw_card *card,
wait_for_completion_timeout(&phy_config_done, timeout);
}

+static DEFINE_SPINLOCK(address_handler_list_lock);
+static __guarded_by(RCU, &address_handler_list_lock) LIST_HEAD(address_handler_list);
+
static struct fw_address_handler *lookup_overlapping_address_handler(
struct list_head *list, unsigned long long offset, size_t length)
+__must_hold(address_handler_list_lock)
{
struct fw_address_handler *handler;

- list_for_each_entry_rcu(handler, list, link) {
+ lockdep_assert_held(&address_handler_list_lock);
+
+ list_for_each_entry(handler, list, link) {
if (handler->offset < offset + length &&
offset < handler->offset + handler->length)
return handler;
@@ -613,6 +619,7 @@ static bool is_enclosing_handler(struct fw_address_handler *handler,

static struct fw_address_handler *lookup_enclosing_address_handler(
struct list_head *list, unsigned long long offset, size_t length)
+__must_hold_shared(RCU)
{
struct fw_address_handler *handler;

@@ -624,9 +631,6 @@ static struct fw_address_handler *lookup_enclosing_address_handler(
return NULL;
}

-static DEFINE_SPINLOCK(address_handler_list_lock);
-static LIST_HEAD(address_handler_list);
-
/**
* var fw_high_memory_region - An address range for high memory.
*
--
2.53.0