[dpdk-dev] [PATCH] libs/power: fix the resource leaking issue
David Hunt
david.hunt at intel.com
Tue Jan 15 11:01:37 CET 2019
From: Liang Ma <liang.j.ma at 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 at intel.com>
Reviewed-by: Lei Yao <lei.a.yao at intel.com>
Tested-by: Lei Yao <lei.a.yao at intel.com>
Signed-off-by: David Hunt <david.hunt at 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
More information about the dev
mailing list