From patchwork Mon Nov 26 04:44:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Dillow X-Patchwork-Id: 1800291 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 430203FC54 for ; Mon, 26 Nov 2012 04:55:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754277Ab2KZEzf (ORCPT ); Sun, 25 Nov 2012 23:55:35 -0500 Received: from matrix.voodoobox.net ([75.127.97.206]:38059 "EHLO matrix.voodoobox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754227Ab2KZEzN (ORCPT ); Sun, 25 Nov 2012 23:55:13 -0500 X-Greylist: delayed 640 seconds by postgrey-1.27 at vger.kernel.org; Sun, 25 Nov 2012 23:55:05 EST Received: from shed.thedillows.org ([IPv6:2001:470:8:bf8:218:f3ff:fe04:4c7d]) by matrix.voodoobox.net (8.13.8/8.13.8) with ESMTP id qAQ4iO7D013710 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 25 Nov 2012 23:44:24 -0500 Received: from obelisk.thedillows.org (obelisk.thedillows.org [192.168.0.10]) by shed.thedillows.org (8.14.4/8.14.4) with ESMTP id qAQ4iND7005451 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 25 Nov 2012 23:44:23 -0500 Received: from obelisk.thedillows.org (localhost [127.0.0.1]) by obelisk.thedillows.org (8.14.5/8.14.4) with ESMTP id qAQ4iNS9024543; Sun, 25 Nov 2012 23:44:23 -0500 Received: (from dad@localhost) by obelisk.thedillows.org (8.14.5/8.14.5/Submit) id qAQ4iMhP024542; Sun, 25 Nov 2012 23:44:22 -0500 X-Authentication-Warning: obelisk.thedillows.org: dad set sender to dillowda@ornl.gov using -f From: David Dillow To: linux-rdma@vger.kernel.org Cc: linux-scsi@vger.kernel.org, bvanassche@acm.org, roland@purestorage.com, FUJITA Tomonori , Robert Jennings Subject: [PATCH 08/11] srp_transport: Fix attribute registration Date: Sun, 25 Nov 2012 23:44:13 -0500 Message-Id: X-Mailer: git-send-email 1.7.7.6 In-Reply-To: References: In-Reply-To: References: Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Bart Van Assche 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 Cc: Robert Jennings Signed-off-by: Bart Van Assche Signed-off-by: David Dillow --- drivers/scsi/scsi_transport_srp.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) 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;