[dpdk-dev] [PATCH] power: fix resource leak
Anatoly Burakov
anatoly.burakov at intel.com
Tue Apr 13 14:22:08 CEST 2021
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 at intel.com
Cc: reshma.pattan at intel.com
Signed-off-by: Anatoly Burakov <anatoly.burakov at 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.
lib/librte_power/power_pstate_cpufreq.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
index ec745153d3..1451a024be 100644
--- a/lib/librte_power/power_pstate_cpufreq.c
+++ b/lib/librte_power/power_pstate_cpufreq.c
@@ -185,6 +185,9 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
base_max_ratio =
strtoul(buf_base, NULL, POWER_CONVERT_TO_DECIMAL)
/ BUS_FREQ;
+ /* not needed any more */
+ fclose(f_base_max);
+ f_base_max = NULL;
}
snprintf(fullpath_min, sizeof(fullpath_min), POWER_SYSFILE_MIN_FREQ,
--
2.25.1
More information about the dev
mailing list