DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: david.hunt@intel.com, reshma.pattan@intel.com
Subject: [dpdk-dev] [PATCH v2] power: fix resource leak
Date: Wed, 14 Apr 2021 10:07:00 +0000	[thread overview]
Message-ID: <20210414100700.127129-1-anatoly.burakov@intel.com> (raw)
In-Reply-To: <20210413122208.101057-1-anatoly.burakov@intel.com>

Currently, we open the system base frequency file, but never close it,
which results in a memory leak.

Coverity issue: 369693

Fixes: 8a5febaac4f7 ("power: fix P-state base frequency handling")
Cc: david.hunt@intel.com
Cc: reshma.pattan@intel.com

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---

Notes:
    Ideally, the close should be added at the end, but there's a bunch of ERR_RET
    macros before that, so addressing that would put us dangerously close to
    refactoring, which is not what we want to do so close to the release.
    
    This issue was already "fixed", but because the variable naming and the flow of
    code is confusing, the fix was addressing a different variable. There is a
    patch for 21.08 that will address the code flow and make it less confusing.
    
    v2:
    - Move the fd close to before we check read data

 lib/librte_power/power_pstate_cpufreq.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
index ec745153d3..2cfc54acf3 100644
--- a/lib/librte_power/power_pstate_cpufreq.c
+++ b/lib/librte_power/power_pstate_cpufreq.c
@@ -175,6 +175,11 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	FOPEN_OR_ERR_RET(f_base_max, -1);
 	if (f_base_max != NULL) {
 		s_base_max = fgets(buf_base, sizeof(buf_base), f_base_max);
+
+		/* close the file unconditionally */
+		fclose(f_base_max);
+		f_base_max = NULL;
+
 		FOPS_OR_NULL_GOTO(s_base_max, out);
 
 		buf_base[BUFSIZ-1] = '\0';
-- 
2.25.1


  parent reply	other threads:[~2021-04-14 10:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13 12:22 [dpdk-dev] [PATCH] " Anatoly Burakov
2021-04-14  9:24 ` Pattan, Reshma
2021-04-14 10:00   ` Burakov, Anatoly
2021-04-14 10:02     ` Burakov, Anatoly
2021-04-14 10:07 ` Anatoly Burakov [this message]
2021-04-14 10:16   ` [dpdk-dev] [PATCH v2] " Pattan, Reshma
2021-04-15 21:55     ` 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=20210414100700.127129-1-anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    --cc=reshma.pattan@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).