From patchwork Wed Jan 15 20:28:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 3493641 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 822D89F32F for ; Wed, 15 Jan 2014 20:28:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7AB5E20155 for ; Wed, 15 Jan 2014 20:28:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D2C7920154 for ; Wed, 15 Jan 2014 20:28:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751538AbaAOU2a (ORCPT ); Wed, 15 Jan 2014 15:28:30 -0500 Received: from mail-ea0-f180.google.com ([209.85.215.180]:60729 "EHLO mail-ea0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751314AbaAOU2a (ORCPT ); Wed, 15 Jan 2014 15:28:30 -0500 Received: by mail-ea0-f180.google.com with SMTP id f15so711756eak.39 for ; Wed, 15 Jan 2014 12:28:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=4d22qp+1ic/arRQdrc1p7Lrjaj0G0qQGR8sFG5BYyOI=; b=FYpQR7r9B480kIEsG+r5Ajj86nSZT5vZRY4sqHtiaIkokU4KGKeCCexqdK/JXTDoPt enf4W8OhxgUb8jVJFR40XylJXNMt0o/IPKu6EGurX6hrh8dvssNXVwMpr+tj47/GHxHW efXmEJW9v+3h9sNDP+mgAEA4hQ4UqQJtmsuY+Aszb3LadUWqGSbJGuv2mKOTUlAxPjgJ 44fmqAUzPsl94zm7a2ZTVgW2+h5TK+uOQ3aFSsiM/jUMo9F+TRQUgkwVe0IqteRIv6Uu lQt7Fk2h/+V65nAVJDZdT6BdO1GB4B9RWIrhiRJiqEdwSQXwlmZcUp+YQYvzIvpf8itq IVMw== X-Gm-Message-State: ALoCoQnuWNzAJmWCwToAe4owHVd2gvIU+55ZoqNjaN2ZqMLpLz8cASNR9nvkWo/xoo3PKV77gHsy X-Received: by 10.15.32.73 with SMTP id z49mr6519526eeu.27.1389817708699; Wed, 15 Jan 2014 12:28:28 -0800 (PST) Received: from [192.168.1.102] (c-98-229-118-119.hsd1.ma.comcast.net. [98.229.118.119]) by mx.google.com with ESMTPSA id 4sm13072427eed.14.2014.01.15.12.28.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 12:28:28 -0800 (PST) Message-ID: <52D6EF6A.9040603@dev.mellanox.co.il> Date: Wed, 15 Jan 2014 15:28:26 -0500 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "linux-rdma (linux-rdma@vger.kernel.org)" CC: Alex Netes Subject: [PATCH opensm 1/4] osm_trap_rcv.c: fix locking in, trap_rcv_process_request() Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 From 280a2ac0ba17b909481ebbd3ed406104629f2a36 Mon Sep 17 00:00:00 2001 From: Alex Netes Date: Wed, 29 Aug 2012 19:31:19 +0300 Subject: [PATCH 1/4] osm_trap_rcv.c: fix locking in trap_rcv_process_request() Write lock should be taken before accessing p_physp. In case of traps 144/145, we also update the physp data. Signed-off-by: Alex Netes Signed-off-by: Hal Rosenstock --- opensm/osm_trap_rcv.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/opensm/osm_trap_rcv.c b/opensm/osm_trap_rcv.c index 663fa35..9d7ed74 100644 --- a/opensm/osm_trap_rcv.c +++ b/opensm/osm_trap_rcv.c @@ -447,7 +447,7 @@ static void trap_rcv_process_request(IN osm_sm_t * sm, } osm_dump_notice_v2(sm->p_log, p_ntci, FILE_ID, OSM_LOG_VERBOSE); - + CL_PLOCK_EXCL_ACQUIRE(sm->p_lock); p_physp = osm_get_physp_by_mad_addr(sm->p_log, sm->p_subn, &tmp_madw.mad_addr); if (p_physp) @@ -545,9 +545,7 @@ static void trap_rcv_process_request(IN osm_sm_t * sm, OSM_LOG(sm->p_log, OSM_LOG_INFO, "Trap 144 Node description update\n"); if (p_physp) { - CL_PLOCK_ACQUIRE(sm->p_lock); osm_req_get_node_desc(sm, p_physp); - CL_PLOCK_RELEASE(sm->p_lock); if (!(p_ntci->data_details.ntc_144.change_flgs & ~TRAP_144_MASK_NODE_DESCRIPTION_CHANGE) && p_ntci->data_details.ntc_144.new_cap_mask == p_physp->port_info.capability_mask) goto check_report; @@ -647,9 +645,7 @@ check_report: } /* we need a lock here as the InformInfo DB must be stable */ - CL_PLOCK_ACQUIRE(sm->p_lock); status = osm_report_notice(sm->p_log, sm->p_subn, p_ntci); - CL_PLOCK_RELEASE(sm->p_lock); if (status != IB_SUCCESS) { OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3803: " "Error sending trap reports (%s)\n", @@ -658,6 +654,7 @@ check_report: } Exit: + CL_PLOCK_RELEASE(sm->p_lock); OSM_LOG_EXIT(sm->p_log); }