linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>
Cc: David Dillow <dillowda@ornl.gov>,
	Roland Dreier <roland@purestorage.com>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
	Robert Jennings <rcj@linux.vnet.ibm.com>
Subject: [PATCH 11/19] srp_transport: Fix attribute registration
Date: Fri, 26 Oct 2012 14:52:43 +0200	[thread overview]
Message-ID: <508A879B.3010502@acm.org> (raw)
In-Reply-To: <508A85BB.1000505@acm.org>

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.

Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Robert Jennings <rcj@linux.vnet.ibm.com>
Cc: David Dillow <dillowda@ornl.gov>
Cc: Roland Dreier <roland@purestorage.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_transport_srp.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index 21a045e..07c4394 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)
 	i->rport_attr_cont.ac.attrs = &i->rport_attrs[0];
 	i->rport_attr_cont.ac.class = &srp_rport_class.class;
 	i->rport_attr_cont.ac.match = srp_rport_match;
-	transport_container_register(&i->rport_attr_cont);
 
 	count = 0;
 	SETUP_RPORT_ATTRIBUTE_RD(port_id);
 	SETUP_RPORT_ATTRIBUTE_RD(roles);
 	i->rport_attrs[count] = NULL;
 
+	transport_container_register(&i->rport_attr_cont);
+
 	i->f = ft;
 
 	return &i->t;
-- 
1.7.10.4


  reply	other threads:[~2012-10-26 12:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-26 12:44 [PATCH 00/19, v5] Make ib_srp better suited for H.A. purposes Bart Van Assche
2012-10-26 12:52 ` Bart Van Assche [this message]
2012-10-26 12:54 ` [PATCH 13/19] srp_transport: Document sysfs attributes Bart Van Assche
2012-10-26 12:55 ` [PATCH 14/19] ib_srp: Allow SRP disconnect through sysfs Bart Van Assche
     [not found] ` <508A85BB.1000505-HInyCGIudOg@public.gmane.org>
2012-10-26 12:53   ` [PATCH 12/19] srp_transport: Simplify attribute initialization code Bart Van Assche
2012-10-26 12:56   ` [PATCH 16/19] srp_transport: Add transport layer error handling Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=508A879B.3010502@acm.org \
    --to=bvanassche@acm.org \
    --cc=dillowda@ornl.gov \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=rcj@linux.vnet.ibm.com \
    --cc=roland@purestorage.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).