From b9d9a226589277aad5d82ce8e922b754766f672d Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sun, 20 Sep 2026 16:14:57 +0900 Subject: [PATCH] firewire: cdev: use memory barrier to access fw_device members The core code uses a read memory barrier when accessing the generation and node_id members of the fw_device structure. It assumes that the latest value of the former is visible to a processor core when the latest value of the latter is visible, since these members are updated in reverse order with a write memory barrier. However, the function that fills the fw_cdev_event_bus_reset structure does not follow this approach. Use a read memory barrier when accessing these members. Link: https://lore.kernel.org/r/20260920071501.77785-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 664952a67a11..3277eec98d93 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -399,18 +399,21 @@ static ssize_t fw_device_op_read(struct file *file, char __user *buffer, static void fill_bus_reset_event(struct fw_cdev_event_bus_reset *event, struct client *client) { - struct fw_card *card = client->device->card; - - guard(spinlock_irq)(&card->lock); - event->closure = client->bus_reset_closure; event->type = FW_CDEV_EVENT_BUS_RESET; + event->generation = client->device->generation; + smp_rmb(); event->node_id = client->device->node_id; - event->local_node_id = card->local_node->node_id; - event->bm_node_id = card->bm_node_id; - event->irm_node_id = card->irm_node->node_id; - event->root_node_id = card->root_node->node_id; + + struct fw_card *card = client->device->card; + + scoped_guard(spinlock_irq, &card->lock) { + event->local_node_id = card->local_node->node_id; + event->bm_node_id = card->bm_node_id; + event->irm_node_id = card->irm_node->node_id; + event->root_node_id = card->root_node->node_id; + } } static void for_each_client(struct fw_device *device,