From patchwork Thu May 30 14:38:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Line Holen X-Patchwork-Id: 2637001 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id D78F5DF2A1 for ; Thu, 30 May 2013 14:39:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932777Ab3E3OjE (ORCPT ); Thu, 30 May 2013 10:39:04 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:45270 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933084Ab3E3OjB convert rfc822-to-8bit (ORCPT ); Thu, 30 May 2013 10:39:01 -0400 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r4UEcugZ024465 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 30 May 2013 14:38:57 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r4UEcv4F015795 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 30 May 2013 14:38:57 GMT Received: from abhmt107.oracle.com (abhmt107.oracle.com [141.146.116.59]) by userz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r4UEcvdG015782; Thu, 30 May 2013 14:38:57 GMT MIME-Version: 1.0 Message-ID: <66f50a5a-e3dc-452c-ae73-9b07e2c12b3e@default> Date: Thu, 30 May 2013 07:38:56 -0700 (PDT) From: Line Holen To: Cc: Subject: [PATCH] osm_console_io.c Memory leak when closing console X-Mailer: Zimbra on Oracle Beehive Content-Disposition: inline X-Source-IP: ucsinet22.oracle.com [156.151.31.94] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Use fclose() rather than close() to avoid memory leaks. Also lowered the loglevel of a couple of log messages. Signed-off-by: Line Holen --- -- 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_console_io.c b/opensm/osm_console_io.c index 18bd5ef..dfc903f 100644 --- a/opensm/osm_console_io.c +++ b/opensm/osm_console_io.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2005-2009 Voltaire, Inc. All rights reserved. * Copyright (c) 2008 HNR Consulting. All rights reserved. + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -107,10 +108,10 @@ int cio_close(osm_console_t * p_oct, osm_log_t * p_log) { int rtnval = -1; if (p_oct && p_oct->in_fd > 0) { - OSM_LOG(p_log, OSM_LOG_INFO, + OSM_LOG(p_log, OSM_LOG_VERBOSE, "Console connection closed: %s (%s)\n", p_oct->client_hn, p_oct->client_ip); - rtnval = close(p_oct->in_fd); + rtnval = fclose(p_oct->in); p_oct->in_fd = -1; p_oct->out_fd = -1; p_oct->in = NULL; @@ -138,9 +139,10 @@ int cio_open(osm_console_t * p_oct, int new_fd, osm_log_t * p_log) cio_close(p_oct, p_log); else { OSM_LOG(p_log, OSM_LOG_INFO, - "Console connection aborted: %s (%s)\n", + "Console connection aborted: %s (%s) - " + "already in use\n", p_oct->client_hn, p_oct->client_ip); - close(new_fd); + fclose(file); free(p_line); return -1; } @@ -151,7 +153,7 @@ int cio_open(osm_console_t * p_oct, int new_fd, osm_log_t * p_log) p_oct->in = fdopen(p_oct->in_fd, "w+"); p_oct->out = p_oct->in; osm_console_prompt(p_oct->out); - OSM_LOG(p_log, OSM_LOG_INFO, "Console connection accepted: %s (%s)\n", + OSM_LOG(p_log, OSM_LOG_VERBOSE, "Console connection accepted: %s (%s)\n", p_oct->client_hn, p_oct->client_ip); return (p_oct->in == NULL) ? -1 : 0; @@ -224,7 +226,7 @@ int osm_console_init(osm_subn_opt_t * opt, osm_console_t * p_oct, osm_log_t * p_ } if (listen(p_oct->socket, 1) < 0) { OSM_LOG(p_log, OSM_LOG_ERROR, - "ERR 4B03: Failed to listen on socket: %s\n", + "ERR 4B03: Failed to listen on console socket: %s\n", strerror(errno)); return -1; }