From patchwork Tue Aug 26 14:33:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreea-Cristina Bernat X-Patchwork-Id: 4782701 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 39AF3C0338 for ; Tue, 26 Aug 2014 14:33:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 36B362012D for ; Tue, 26 Aug 2014 14:33:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B36120127 for ; Tue, 26 Aug 2014 14:33:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755199AbaHZOdc (ORCPT ); Tue, 26 Aug 2014 10:33:32 -0400 Received: from mail-la0-f49.google.com ([209.85.215.49]:49249 "EHLO mail-la0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754610AbaHZOdc (ORCPT ); Tue, 26 Aug 2014 10:33:32 -0400 Received: by mail-la0-f49.google.com with SMTP id hz20so14885784lab.22 for ; Tue, 26 Aug 2014 07:33:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=iM60Tw9rW6CEh3LA8v8mhUlnng6hKud98UK9qVZBAew=; b=E+YaLzbWbaaH2EIu4nqXh6gkfgiGNqF5F3LJ7654PUeBRZMKrgtP2iv19RuOMEfeQz VXKYrloXyWJBeGc4JU6gru5+Pa5enbHvB1GLnmU1plHpa+VVtlxDDFpdXwdyFLmAXRtb dO0lujZvXh7EQCnb2cF7oK//KBTzkcSNToHfiG8H0k9vv9sLqeb7x1J2J6scDJf4mjqO 7PDslUXWUrBiiNyPFobH/P/tJ44qN5v1ObsHTttfAx/MiLkrmaRfe4Cw11RUMTtLsQ8n tDMw7EqBJZI1FzBNSidnDAVSm49S8vusVfAjKud5oGGTTdWJx6cFT4USOupv2wqT4ZTx ICRw== X-Received: by 10.152.246.37 with SMTP id xt5mr3497048lac.71.1409063610165; Tue, 26 Aug 2014 07:33:30 -0700 (PDT) Received: from ada ([85.204.3.189]) by mx.google.com with ESMTPSA id vl4sm5432276lbb.36.2014.08.26.07.33.28 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 26 Aug 2014 07:33:29 -0700 (PDT) Date: Tue, 26 Aug 2014 17:33:22 +0300 From: Andreea-Cristina Bernat To: infinipath@intel.com, roland@kernel.org, sean.hefty@intel.com, hal.rosenstock@gmail.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: paulmck@linux.vnet.ibm.com Subject: [PATCH] qib: qib_qp: Replace rcu_assign_pointer() with RCU_INIT_POINTER() Message-ID: <20140826143322.GA2498@ada> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to RCU_INIT_POINTER()'s block comment 3.a, it can be used if "3. The referenced data structure has already been exposed to readers either at compile time or via rcu_assign_pointer() -and- a. You have not made -any- reader-visible changes to this structure since then". This case fulfills the conditions above because between the rcu_dereference_protected() call and the rcu_assign_pointer() call there is no update of that value. Therefore, this patch makes the replacement. The following Coccinelle semantic patch was used: @@ @@ - rcu_assign_pointer + RCU_INIT_POINTER (..., ( rtnl_dereference(...) | rcu_dereference_protected(...) ) ) Signed-off-by: Andreea-Cristina Bernat --- drivers/infiniband/hw/qib/qib_qp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/qib/qib_qp.c b/drivers/infiniband/hw/qib/qib_qp.c index 17daf42..cb0c680 100644 --- a/drivers/infiniband/hw/qib/qib_qp.c +++ b/drivers/infiniband/hw/qib/qib_qp.c @@ -269,7 +269,7 @@ static void remove_qp(struct qib_ibdev *dev, struct qib_qp *qp) lockdep_is_held(&dev->qpt_lock))) != NULL; qpp = &q->next) if (q == qp) { - rcu_assign_pointer(*qpp, + RCU_INIT_POINTER(*qpp, rcu_dereference_protected(qp->next, lockdep_is_held(&dev->qpt_lock))); removed = 1;