From patchwork Mon Feb 24 12:52:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 3709081 X-Patchwork-Delegate: hal@mellanox.com 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 E4A84BF13A for ; Mon, 24 Feb 2014 12:52:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 112262010F for ; Mon, 24 Feb 2014 12:52:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B7DD520121 for ; Mon, 24 Feb 2014 12:52:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752616AbaBXMwx (ORCPT ); Mon, 24 Feb 2014 07:52:53 -0500 Received: from mail-wg0-f54.google.com ([74.125.82.54]:43990 "EHLO mail-wg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752163AbaBXMww (ORCPT ); Mon, 24 Feb 2014 07:52:52 -0500 Received: by mail-wg0-f54.google.com with SMTP id l18so4707223wgh.9 for ; Mon, 24 Feb 2014 04:52:51 -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=FOmqYriiMvob3SpM3nlIut7QMIHWhC8d5dok1LlEE3w=; b=kWZxMKDl9iRi7xzfey9/6ynMKZ5iCTNd7k7Hz8MszZv6wtodZP+47V84ThY4evbKYH cPKizWrlDT50gNFqfK4Gidijw+4FVcTnNslvA875wd/1tmnHVn7jAGlh3MtNxNBOzTa8 adpk/KXo7X4xH/BvpXw1NF/2OHDx7b5dCNUkmTeiohgoAID34FJfoquGpHk3SIIdo8ck 79+K4YlfxxZPAomFb3/0JHU6p8sVBqiGEPJLoS8AmkLiwcWWkshMndnoXIjhYhkxauB8 nDKioSJRqMFtjHgdPHN3FiS6vZ12SUWgColGzPaNinOiAxZtvt33cftOOhXty6iVItbz 9Mzg== X-Gm-Message-State: ALoCoQk0uk0knU0/KLgK8E5W+7ejKTcwybxQaDot/5o5eGkzZObYVCLZnyqFpJU1MGLzPt7pzQCJ X-Received: by 10.194.90.177 with SMTP id bx17mr18582242wjb.91.1393246371533; Mon, 24 Feb 2014 04:52:51 -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 n3sm24017627wix.10.2014.02.24.04.52.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Feb 2014 04:52:51 -0800 (PST) Message-ID: <530B40A0.2090804@dev.mellanox.co.il> Date: Mon, 24 Feb 2014 07:52:48 -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: "rafiw@mellanox.com" Subject: [PATCH opensm] osm_ucast_ftree.c: Fix memory leak in ftree fabric_rank 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.9 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: Rafi Wiener Memory leak is due to double cl_list_init calls. It happens when OpenSM cannot parse root guids file. Also, cosmetic formatting change Signed-off-by: Rafi Wiener --- opensm/osm_ucast_ftree.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/opensm/osm_ucast_ftree.c b/opensm/osm_ucast_ftree.c index ee37e79..f646bd0 100644 --- a/opensm/osm_ucast_ftree.c +++ b/opensm/osm_ucast_ftree.c @@ -3555,7 +3555,6 @@ static boolean_t fabric_load_roots(IN ftree_fabric_t * p_ftree, unsigned num_roots; if (p_ranking_bfs_list) { - cl_list_init(p_ranking_bfs_list, 10); /* Rank all the roots and add them to list */ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG, @@ -3709,7 +3708,6 @@ static int fabric_rerank_using_root(IN ftree_fabric_t * p_ftree, int res; OSM_LOG_ENTER(&p_ftree->p_osm->log); - cl_list_init(p_ranking_bfs_list, 10); p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl); while (p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) { @@ -3732,10 +3730,11 @@ static int fabric_rank(IN ftree_fabric_t * p_ftree) cl_list_t ranking_bfs_list; OSM_LOG_ENTER(&p_ftree->p_osm->log); + cl_list_init(&ranking_bfs_list, 10); if (fabric_roots_provided(p_ftree) && fabric_load_roots(p_ftree, &ranking_bfs_list)) - res = fabric_rank_from_roots(p_ftree, &ranking_bfs_list); + res = fabric_rank_from_roots(p_ftree, &ranking_bfs_list); else { res = fabric_rank_from_hcas(p_ftree); if (!res)