linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Line Holen <line.holen-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH] osm_console_io.c Memory leak when closing console
Date: Thu, 30 May 2013 07:38:56 -0700 (PDT)	[thread overview]
Message-ID: <66f50a5a-e3dc-452c-ae73-9b07e2c12b3e@default> (raw)

Use fclose() rather than close() to avoid memory leaks.
Also lowered the loglevel of a couple of log messages.

Signed-off-by: Line Holen <Line.Holen-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

---

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;
 		}
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2013-05-30 14:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-30 14:38 Line Holen [this message]
2013-05-31  9:48 ` [PATCH] osm_console_io.c Memory leak when closing console Hal Rosenstock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=66f50a5a-e3dc-452c-ae73-9b07e2c12b3e@default \
    --to=line.holen-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).