From: Liang Ma Date: Tue, 15 Jan 2019 10:01:37 +0000 (+0000) Subject: power: fix file descriptor leak X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7c06d9258ab8a33b4d5a6604726ebeae90d8537e;p=dpdk.git power: fix file descriptor leak Coverity issue: 328528 Fixes: e6c6dc0f96c8 ("power: add p-state driver compatibility") Signed-off-by: Liang Ma Reviewed-by: Lei Yao Tested-by: Lei Yao Signed-off-by: David Hunt --- diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c index c4d972fc03..9c1a1625fb 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c @@ -160,6 +160,9 @@ 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 +401,9 @@ 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);