From patchwork Mon Mar 7 10:03:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Netes X-Patchwork-Id: 615231 X-Patchwork-Delegate: alexne@voltaire.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p27A3MWI005731 for ; Mon, 7 Mar 2011 10:03:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755582Ab1CGKDV (ORCPT ); Mon, 7 Mar 2011 05:03:21 -0500 Received: from mail.mellanox.co.il ([194.90.237.43]:40494 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754511Ab1CGKDU (ORCPT ); Mon, 7 Mar 2011 05:03:20 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from alexne@mellanox.com) with SMTP; 7 Mar 2011 12:12:13 +0200 Received: from MTRCASDAG01.mtl.com (172.25.0.174) by MTLCAS02.mtl.com (10.0.8.72) with Microsoft SMTP Server (TLS) id 14.1.270.1; Mon, 7 Mar 2011 12:03:08 +0200 Received: from localhost (172.25.6.157) by MTRCASDAG01.mtl.com (172.25.0.174) with Microsoft SMTP Server (TLS) id 14.1.270.1; Mon, 7 Mar 2011 12:03:07 +0200 Date: Mon, 7 Mar 2011 12:03:02 +0200 From: Alex Netes To: Subject: [PATCH] opensm: fixed memory leak in osm_console() Message-ID: <20110307100302.GJ5577@calypso.voltaire.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Originating-IP: [172.25.6.157] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 07 Mar 2011 10:03:22 +0000 (UTC) diff --git a/opensm/osm_console.c b/opensm/osm_console.c index fad80ad..7003508 100644 --- a/opensm/osm_console.c +++ b/opensm/osm_console.c @@ -1279,6 +1279,8 @@ static void dump_portguid_parse(char **p_last, osm_opensm_t * p_osm, FILE * out) if (strcmp(p_cmd, "file") == 0) { p_cmd = next_token(p_last); if (p_cmd) { + if (output != out) + fclose(output); output = fopen(p_cmd, "w+"); if (output == NULL) { fprintf(out,