aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2011-10-21 13:31:07 -0400
committerRoland Dreier <roland@purestorage.com>2012-11-30 20:40:33 -0500
commitac9be30e91cffe07f762bd91ca40de065bf257d7 (patch)
tree94f6a1ced9a91c53d3c626ab81929d25fea2caa3
parenta4605a93696ee0768e55e4bce1ff7f0ee39bcf79 (diff)
srp_transport: Fix attribute registration
Register transport attributes after the attribute array has been set up instead of before. The current code can trigger a race condition because the code reading the attribute array can run on another thread than the code that initialized that array. Make sure that any code reading the attribute array will see all values written into that array. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: Robert Jennings <rcj@linux.vnet.ibm.com> Acked-by: David Dillow <dillowda@ornl.gov> Signed-off-by: Roland Dreier <roland@purestorage.com>
-rw-r--r--drivers/scsi/scsi_transport_srp.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index 21a045e0559f..07c4394624f1 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -324,13 +324,14 @@ srp_attach_transport(struct srp_function_template *ft)
324 i->rport_attr_cont.ac.attrs = &i->rport_attrs[0]; 324 i->rport_attr_cont.ac.attrs = &i->rport_attrs[0];
325 i->rport_attr_cont.ac.class = &srp_rport_class.class; 325 i->rport_attr_cont.ac.class = &srp_rport_class.class;
326 i->rport_attr_cont.ac.match = srp_rport_match; 326 i->rport_attr_cont.ac.match = srp_rport_match;
327 transport_container_register(&i->rport_attr_cont);
328 327
329 count = 0; 328 count = 0;
330 SETUP_RPORT_ATTRIBUTE_RD(port_id); 329 SETUP_RPORT_ATTRIBUTE_RD(port_id);
331 SETUP_RPORT_ATTRIBUTE_RD(roles); 330 SETUP_RPORT_ATTRIBUTE_RD(roles);
332 i->rport_attrs[count] = NULL; 331 i->rport_attrs[count] = NULL;
333 332
333 transport_container_register(&i->rport_attr_cont);
334
334 i->f = ft; 335 i->f = ft;
335 336
336 return &i->t; 337 return &i->t;