From patchwork Thu Aug 22 14:31:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 2848286 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 2E27D9F271 for ; Thu, 22 Aug 2013 14:31:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F0E6205BC for ; Thu, 22 Aug 2013 14:31:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C59E4205B4 for ; Thu, 22 Aug 2013 14:31:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753355Ab3HVObO (ORCPT ); Thu, 22 Aug 2013 10:31:14 -0400 Received: from mail-ee0-f51.google.com ([74.125.83.51]:55477 "EHLO mail-ee0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753373Ab3HVObN (ORCPT ); Thu, 22 Aug 2013 10:31:13 -0400 Received: by mail-ee0-f51.google.com with SMTP id c1so971377eek.10 for ; Thu, 22 Aug 2013 07:31:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=gwTy58ggA9cipWk5xeMa5h2Fw1pKZsmeBpSa/PN4eAk=; b=iG+uZE/yZ2s3nh30Hnkjf3kOmK18bTzRmbIbRhH8NNPgEMcHB+KEF8DzYeiRYToleN vKpYqzbWtWjmUU2C8eN5/A/L/4znUvxDmwqomErnWYeFZS6IicNrk3a1UpqmV2ppWgbI xGq1iBHjxB8ifo/JzOqlEzG31DzOp6NPr+AQ5Ica56p6RBXSAqdXOqTyG2PG+8g2j6gM 7+UJooIGQvk6f0LE/FNvy5WtQZ562cdZtvfNs3cSRMTWYAT85OuNPecUz3i96RWoeclU LpsiVZtfg1FC6UF4UHiXRNciZsM9EcBaIfnrI20NLFwIwAG25dRm3uGKNrhjTnwxzo6S R1AQ== X-Gm-Message-State: ALoCoQlghSPSlG3gPWeIOei6sKnN4SvP+sZyW9LMopJdnZUc3yE/lamwRB0FJXI6AluWmeqwxWKN X-Received: by 10.15.36.9 with SMTP id h9mr19331285eev.30.1377181872085; Thu, 22 Aug 2013 07:31:12 -0700 (PDT) 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 x47sm17933191eea.16.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 Aug 2013 07:31:11 -0700 (PDT) Message-ID: <521620AA.5030906@dev.mellanox.co.il> Date: Thu, 22 Aug 2013 10:31:06 -0400 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] osm_trap_rcv.c: Fix locking in aging callback Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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: Alex Netes Callback execution should be under read lock as it accesses global data. Signed-off-by: Alex Netes Signed-off-by: Hal Rosenstock --- opensm/osm_trap_rcv.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/opensm/osm_trap_rcv.c b/opensm/osm_trap_rcv.c index 4e59a17..6a7936d 100644 --- a/opensm/osm_trap_rcv.c +++ b/opensm/osm_trap_rcv.c @@ -115,6 +115,8 @@ static uint64_t aging_tracker_callback(IN uint64_t key, IN uint32_t num_regs, lid = (ib_net16_t) ((key & 0x0000FFFF00000000ULL) >> 32); port_num = (uint8_t) ((key & 0x00FF000000000000ULL) >> 48); + CL_PLOCK_ACQUIRE(sm->p_lock); + p_physp = get_physp_by_lid_and_num(sm, lid, port_num); if (!p_physp) { OSM_LOG(sm->p_log, OSM_LOG_VERBOSE, @@ -140,5 +142,6 @@ static uint64_t aging_tracker_callback(IN uint64_t key, IN uint32_t num_regs, } + CL_PLOCK_RELEASE(sm->p_lock); OSM_LOG_EXIT(sm->p_log); /* We want to remove the event from the tracker - so