Two fixes:
  - There was a small window where a login or reconnect job could use an
    already updated card generation with an outdated node ID.  We better
    use the fw_device.generation here, not the fw_card.generation.
  - Insert a memory barrier to ensure that the device generation is read
    before the node ID.  This is to guarantee that the generation is not
    newer than the node ID.

A small optimization:
  - The target's and initiator's node IDs can be obtained from fw_device
    and fw_card.  Dereferencing their underlying topology objects is not
    necessary.

Signed-off-by: Stefan Richter <[EMAIL PROTECTED]>
---
 drivers/firewire/fw-sbp2.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Index: linux/drivers/firewire/fw-sbp2.c
===================================================================
--- linux.orig/drivers/firewire/fw-sbp2.c
+++ linux/drivers/firewire/fw-sbp2.c
@@ -643,9 +643,10 @@ static void sbp2_login(struct work_struc
        struct sbp2_login_response response;
        int generation, node_id, local_node_id;
 
-       generation    = device->card->generation;
-       node_id       = device->node->node_id;
-       local_node_id = device->card->local_node->node_id;
+       generation    = device->generation;
+       rmb();
+       node_id       = device->node_id;
+       local_node_id = device->card->node_id;
 
        if (sbp2_send_management_orb(lu, node_id, generation,
                                SBP2_LOGIN_REQUEST, lu->lun, &response) < 0) {
@@ -900,9 +901,10 @@ static void sbp2_reconnect(struct work_s
        struct fw_device *device = fw_device(unit->device.parent);
        int generation, node_id, local_node_id;
 
-       generation    = device->card->generation;
-       node_id       = device->node->node_id;
-       local_node_id = device->card->local_node->node_id;
+       generation    = device->generation;
+       rmb();
+       node_id       = device->node_id;
+       local_node_id = device->card->node_id;
 
        if (sbp2_send_management_orb(lu, node_id, generation,
                                     SBP2_RECONNECT_REQUEST,

-- 
Stefan Richter
-=====-=-=== =-== ----=
http://arcgraph.de/sr/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to