patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Roman Korynkevych <romanx.korynkevych@intel.com>
To: dev@dpdk.org
Cc: harry.van.haaren@intel.com, maryam.tahhan@intel.com,
	Roman Korynkevych <romanx.korynkevych@intel.com>,
	stable@dpdk.org
Subject: [dpdk-stable] [PATCH v1 1/1] app/procinfo: resource leak fix.
Date: Fri,  5 May 2017 15:47:29 +0100	[thread overview]
Message-ID: <1493995649-3220-1-git-send-email-romanx.korynkevych@intel.com> (raw)

Coverity issue: 143256
Fixes: 2deb6b5246d7706448d070335b329d1acb754cee ("app/procinfo: add collectd format and host id")
Cc: stable@dpdk.org

Signed-off-by: Roman Korynkevych <romanx.korynkevych@intel.com>
---
 app/proc_info/main.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index 17a1c87..3d0b621 100644
--- a/app/proc_info/main.c
+++ b/app/proc_info/main.c
@@ -75,7 +75,7 @@ static uint32_t enable_xstats;
 /**< Enable collectd format*/
 static uint32_t enable_collectd_format;
 /**< FD to send collectd format messages to STDOUT*/
-static int stdout_fd;
+static int stdout_fd = -1;
 /**< Host id process is running on */
 static char host_id[MAX_LONG_OPT_SZ];
 /**< Enable metrics. */
@@ -637,28 +637,37 @@ main(int argc, char **argv)
 	argc += 3;
 
 	ret = rte_eal_init(argc, argp);
-	if (ret < 0)
+	if (ret < 0) {
+		close(stdout_fd);
 		rte_panic("Cannot init EAL\n");
+	}
 
 	argc -= ret;
 	argv += (ret - 3);
 
-	if (!rte_eal_primary_proc_alive(NULL))
+	if (!rte_eal_primary_proc_alive(NULL)) {
+		close(stdout_fd);
 		rte_exit(EXIT_FAILURE, "No primary DPDK process is running.\n");
+	}
 
 	/* parse app arguments */
 	ret = proc_info_parse_args(argc, argv);
-	if (ret < 0)
+	if (ret < 0) {
+		close(stdout_fd);
 		rte_exit(EXIT_FAILURE, "Invalid argument\n");
+	}
 
 	if (mem_info) {
 		meminfo_display();
+		close(stdout_fd);
 		return 0;
 	}
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports == 0)
+	if (nb_ports == 0) {
+		close(stdout_fd);
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
+	}
 
 	/* If no port mask was specified*/
 	if (enabled_port_mask == 0)
@@ -688,5 +697,7 @@ main(int argc, char **argv)
 	if (enable_metrics)
 		metrics_display(RTE_METRICS_GLOBAL);
 
+	close(stdout_fd);
+
 	return 0;
 }
-- 
2.1.0

             reply	other threads:[~2017-05-05 14:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-05 14:47 Roman Korynkevych [this message]
2017-05-09 13:38 ` [dpdk-stable] [dpdk-dev] " Pattan, Reshma

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=1493995649-3220-1-git-send-email-romanx.korynkevych@intel.com \
    --to=romanx.korynkevych@intel.com \
    --cc=dev@dpdk.org \
    --cc=harry.van.haaren@intel.com \
    --cc=maryam.tahhan@intel.com \
    --cc=stable@dpdk.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).