From patchwork Mon Oct 28 15:09:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 3103081 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 9D0E19F431 for ; Mon, 28 Oct 2013 15:10:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 111B120250 for ; Mon, 28 Oct 2013 15:10:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 00DDB2029B for ; Mon, 28 Oct 2013 15:10:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932470Ab3J1PJ6 (ORCPT ); Mon, 28 Oct 2013 11:09:58 -0400 Received: from mail-ee0-f54.google.com ([74.125.83.54]:57345 "EHLO mail-ee0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932434Ab3J1PJ5 (ORCPT ); Mon, 28 Oct 2013 11:09:57 -0400 Received: by mail-ee0-f54.google.com with SMTP id t10so3316478eei.27 for ; Mon, 28 Oct 2013 08:09:56 -0700 (PDT) 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=DOBjie5o3S8CqhFJyzp9IEzh5gakm/9lbeSM7pgcTe4=; b=ikQQTrevci1YGKqRdaYWkmWqznXJqlLjcabIwuks1Qm/W4Q+Ctu7xEfLoR3TDM6AW2 Y9HVm9gxmGEyTuMqZfQpDy2yTykkv1URfSxNq8orBabXFniAFPiJmYt78EGKz37XukwC PBRmFoiETDd6NjgJtOumOVeoZJ1118+Cu57fLsb86sJ6ZEVRrq7AZ52XGqpVDe4+o9rr vWf1Aqc5SJT2OHFGVDgy3ZaZY6QBq8GS/2lD28TKHFk38kB8auF3eKjwPNxXwPHIKlCR spvkuJ60Fe9cv0g3gMCXPWyorjOPovRRIG0fpBeJ+UXEWoy7eQNK/KnkcyvoifM2cDfN 3Gog== X-Gm-Message-State: ALoCoQmqCNXify5lrCirFt5D48JHKvrxfydND7G3KKi8adMAj4+ojypZLR/3biwjmgFvZspidJ8/ X-Received: by 10.15.49.6 with SMTP id i6mr497975eew.109.1382972996561; Mon, 28 Oct 2013 08:09:56 -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 h45sm58320298eeg.5.2013.10.28.08.09.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 28 Oct 2013 08:09:56 -0700 (PDT) Message-ID: <526E7E42.8060302@dev.mellanox.co.il> Date: Mon, 28 Oct 2013 11:09:54 -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_ucast_cache.c: Fix memory leak in ucast_cache 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.4 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: Alex Netes When invalidating cache p_sw->hops[i] arrays aren't cleared. Signed-off-by: Alex Netes Signed-off-by: Hal Rosenstock --- opensm/osm_ucast_cache.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/opensm/osm_ucast_cache.c b/opensm/osm_ucast_cache.c index e3f7c7b..2238ba3 100644 --- a/opensm/osm_ucast_cache.c +++ b/opensm/osm_ucast_cache.c @@ -114,13 +114,19 @@ static cache_switch_t *cache_sw_new(uint16_t lid_ho, unsigned num_ports) static void cache_sw_destroy(cache_switch_t * p_sw) { + unsigned i; + if (!p_sw) return; if (p_sw->lft) free(p_sw->lft); - if (p_sw->hops) + if (p_sw->hops) { + for (i = 0; i < p_sw->num_hops; i++) + if (p_sw->hops[i]) + free(p_sw->hops[i]); free(p_sw->hops); + } free(p_sw); }