All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: anatoly.burakov@intel.com, david.hunt@intel.com
Subject: [dpdk-dev] [PATCH v3 1/2] power: fix pstate base frequency handling
Date: Thu,  1 Apr 2021 15:06:13 +0000	[thread overview]
Message-ID: <20210401150614.234257-1-anatoly.burakov@intel.com> (raw)
In-Reply-To: <d0dc49e5dab4d4c730cc137194350a7d0a8baca8.1617114301.git.anatoly.burakov@intel.com>

Previous fix for base frequency handling in pstate mode introduced a
couple of issues:

- When base_frequency file does not exist, it simply bails out because
  of what appears to be accidental addition of FOPEN_OR_ERR_RET. This is
  incorrect, as absence of this file is not fatal and is in fact
  expected on kernel versions earlier than 5.3
- When base_frequency file does exist, it gets opened, but never gets
  closed, resulting in a resource leak

Both issues also manifest themselves as Coverity defects (dead code, and
a resource leak), so this fix addresses both.

Fixes: 4db9587bbf72 ("power: check sysfs base frequency")
Cc: david.hunt@intel.com

Coverity issue: 369693
Coverity issue: 369694
Bugzilla ID: 668

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_power/power_pstate_cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
index 8a1fffaed5..af5ad0b506 100644
--- a/lib/librte_power/power_pstate_cpufreq.c
+++ b/lib/librte_power/power_pstate_cpufreq.c
@@ -172,7 +172,6 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 			POWER_SYSFILE_BASE_MAX_FREQ,
 			pi->lcore_id);
 	f_base_max = fopen(fullpath_base_max, "r");
-	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);
 		FOPS_OR_NULL_GOTO(s_base_max, out);
@@ -185,6 +184,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 		base_max_ratio =
 			strtoul(buf_base, NULL, POWER_CONVERT_TO_DECIMAL)
 				/ BUS_FREQ;
+		fclose(f_base_max);
 	}
 
 	snprintf(fullpath_min, sizeof(fullpath_min), POWER_SYSFILE_MIN_FREQ,
-- 
2.25.1


  parent reply	other threads:[~2021-04-01 15:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30 14:15 [dpdk-dev] [PATCH 1/3] power: refactor base frequency detection Anatoly Burakov
2021-03-30 14:15 ` [dpdk-dev] [PATCH 2/3] power: refactor pstate sysfs handling Anatoly Burakov
2021-03-30 14:15 ` [dpdk-dev] [PATCH 3/3] power: do not skip saving original pstate governor Anatoly Burakov
2021-03-30 16:52   ` Burakov, Anatoly
2021-03-30 14:25 ` [dpdk-dev] [PATCH v2 1/3] power: refactor base frequency detection Anatoly Burakov
2021-04-01 15:04   ` [dpdk-dev] [PATCH v2 1/2] power: fix pstate base frequency handling Anatoly Burakov
2021-04-01 15:05   ` [dpdk-dev] [PATCH v2 2/2] power: do not skip saving original pstate governor Anatoly Burakov
2021-04-01 15:06   ` Anatoly Burakov [this message]
2021-04-02  9:26     ` [dpdk-dev] [PATCH v4 1/2] power: fix pstate base frequency handling Anatoly Burakov
2021-04-02  9:35       ` Burakov, Anatoly
2021-04-02 11:12         ` Pattan, Reshma
2021-04-02  9:26     ` [dpdk-dev] [PATCH v4 2/2] power: do not skip saving original pstate governor Anatoly Burakov
2021-04-02  9:34       ` Burakov, Anatoly
2021-04-02 11:12         ` Pattan, Reshma
2021-04-06  8:38           ` Thomas Monjalon
2021-04-01 15:06   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
2021-03-30 14:25 ` [dpdk-dev] [PATCH v2 2/3] power: refactor pstate sysfs handling Anatoly Burakov
2021-03-30 14:25 ` [dpdk-dev] [PATCH v2 3/3] power: do not skip saving original pstate governor Anatoly Burakov
2021-03-30 16:51   ` Burakov, Anatoly

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=20210401150614.234257-1-anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=david.hunt@intel.com \
    --cc=dev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.