DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Hunt <david.hunt@intel.com>
To: dev@dpdk.org
Cc: liang.j.ma@intel.com, lei.a.yao@intel.com,
	David Hunt <david.hunt@intel.com>
Subject: [dpdk-dev] [PATCH] libs/power: fix the resource leaking issue
Date: Tue, 15 Jan 2019 10:01:37 +0000	[thread overview]
Message-ID: <20190115100137.47470-1-david.hunt@intel.com> (raw)
In-Reply-To: <1545996779-4098-1-git-send-email-liang.j.ma@intel.com>

From: Liang Ma <liang.j.ma@intel.com>

Fixes: e6c6dc0f96c8 ("power: add p-state driver compatibility")
Coverity issue: 328528

v2: focus just on the resource leak. Remove additional code around
    Turbo Boost frequency handling.

Signed-off-by: Liang Ma <liang.j.ma@intel.com>
Reviewed-by: Lei Yao <lei.a.yao@intel.com>
Tested-by: Lei Yao <lei.a.yao@intel.com>
Signed-off-by: David Hunt <david.hunt@intel.com>
---
 lib/librte_power/power_pstate_cpufreq.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
index c4d972fc0..079822bf7 100644
--- a/lib/librte_power/power_pstate_cpufreq.c
+++ b/lib/librte_power/power_pstate_cpufreq.c
@@ -160,6 +160,10 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 			pi->lcore_id);
 
 	f_max = fopen(fullpath_max, "rw+");
+
+	if (f_max == NULL)
+		fclose(f_min);
+
 	FOPEN_OR_ERR_RET(f_max, -1);
 
 	pi->f_cur_min = f_min;
@@ -398,6 +402,10 @@ power_get_available_freqs(struct pstate_power_info *pi)
 	FOPEN_OR_ERR_RET(f_min, ret);
 
 	f_max = fopen(fullpath_max, "r");
+
+	if (f_max == NULL)
+		fclose(f_min);
+
 	FOPEN_OR_ERR_RET(f_max, ret);
 
 	s_min = fgets(buf_min, sizeof(buf_min), f_min);
-- 
2.17.1

  parent reply	other threads:[~2019-01-15 10:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-28 11:32 Liang Ma
2019-01-02  2:00 ` Yao, Lei A
2019-01-14 22:35 ` Thomas Monjalon
2019-01-15 10:07   ` Hunt, David
2019-01-15 10:08     ` Thomas Monjalon
2019-01-15 10:01 ` David Hunt [this message]
2019-01-17 17:26   ` Thomas Monjalon

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=20190115100137.47470-1-david.hunt@intel.com \
    --to=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    --cc=lei.a.yao@intel.com \
    --cc=liang.j.ma@intel.com \
    /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).