Commit 92368890d551794ee8d7e90477d8498bb7f82a9b
1 parent
32a0f488ce
Exists in
master
and in
7 other branches
firewire: core: improve check for local node
My recently added test for a device being local in fw-cdev.c got it slightly wrong: Comparisons of node IDs are only valid if the generation is current, which I forgot to check. Normally, serialization by card->lock takes care of this, but a device in FW_DEVICE_GONE state will necessarily have a wrong generation and invalid node_id. The "is it local?" check is made 100% correct and simpler now by means of a struct fw_device flag which is set at fw_device creation. Besides the fw-cdev site which was to be fixed, there is another site which can make use of the new flag, and an RFC-2734 driver will benefit from it too. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Showing 3 changed files with 4 additions and 6 deletions Side-by-side Diff
drivers/firewire/fw-cdev.c
... | ... | @@ -739,15 +739,11 @@ |
739 | 739 | static int ioctl_add_descriptor(struct client *client, void *buffer) |
740 | 740 | { |
741 | 741 | struct fw_cdev_add_descriptor *request = buffer; |
742 | - struct fw_card *card = client->device->card; | |
743 | 742 | struct descriptor_resource *r; |
744 | 743 | int ret; |
745 | 744 | |
746 | 745 | /* Access policy: Allow this ioctl only on local nodes' device files. */ |
747 | - spin_lock_irq(&card->lock); | |
748 | - ret = client->device->node_id != card->local_node->node_id; | |
749 | - spin_unlock_irq(&card->lock); | |
750 | - if (ret) | |
746 | + if (!client->device->is_local) | |
751 | 747 | return -ENOSYS; |
752 | 748 | |
753 | 749 | if (request->length > 256) |
drivers/firewire/fw-device.c
... | ... | @@ -1042,6 +1042,7 @@ |
1042 | 1042 | device->node = fw_node_get(node); |
1043 | 1043 | device->node_id = node->node_id; |
1044 | 1044 | device->generation = card->generation; |
1045 | + device->is_local = node == card->local_node; | |
1045 | 1046 | mutex_init(&device->client_list_mutex); |
1046 | 1047 | INIT_LIST_HEAD(&device->client_list); |
1047 | 1048 | |
... | ... | @@ -1075,7 +1076,7 @@ |
1075 | 1076 | FW_DEVICE_INITIALIZING) == FW_DEVICE_RUNNING) { |
1076 | 1077 | PREPARE_DELAYED_WORK(&device->work, fw_device_refresh); |
1077 | 1078 | schedule_delayed_work(&device->work, |
1078 | - node == card->local_node ? 0 : INITIAL_DELAY); | |
1079 | + device->is_local ? 0 : INITIAL_DELAY); | |
1079 | 1080 | } |
1080 | 1081 | break; |
1081 | 1082 |