* [dpdk-dev] [PATCH v1 1/1] app/procinfo: resource leak fix.
@ 2017-05-05 14:47 Roman Korynkevych
2017-05-09 13:38 ` Pattan, Reshma
0 siblings, 1 reply; 2+ messages in thread
From: Roman Korynkevych @ 2017-05-05 14:47 UTC (permalink / raw)
To: dev; +Cc: harry.van.haaren, maryam.tahhan, Roman Korynkevych, stable
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH v1 1/1] app/procinfo: resource leak fix.
2017-05-05 14:47 [dpdk-dev] [PATCH v1 1/1] app/procinfo: resource leak fix Roman Korynkevych
@ 2017-05-09 13:38 ` Pattan, Reshma
0 siblings, 0 replies; 2+ messages in thread
From: Pattan, Reshma @ 2017-05-09 13:38 UTC (permalink / raw)
To: Korynkevych, RomanX, dev
Cc: Van Haaren, Harry, Tahhan, Maryam, Korynkevych, RomanX, stable
Hi,
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Roman Korynkevych
> Sent: Friday, May 5, 2017 3:47 PM
> To: dev@dpdk.org
> Cc: Van Haaren, Harry <harry.van.haaren@intel.com>; Tahhan, Maryam
> <maryam.tahhan@intel.com>; Korynkevych, RomanX
> <romanx.korynkevych@intel.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH v1 1/1] app/procinfo: resource leak fix.
>
> 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
1)You need to close the stdout_fd even inside proc_info_preparse_args() before return -1;
(or)
inside below piece of code in main().
ret = proc_info_preparse_args(argc, argv);
if (ret < 0) {
printf("Failed to parse arguments\n");
return -1;
}
2)Also if stdout_fd = dup(STDOUT_FILENO); can return negative value, You may need to exit then? If so can you fix that code as well.
Thanks,
Reshma
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-09 13:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-05 14:47 [dpdk-dev] [PATCH v1 1/1] app/procinfo: resource leak fix Roman Korynkevych
2017-05-09 13:38 ` Pattan, Reshma
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).