From: Anatoly Burakov Date: Wed, 14 Apr 2021 10:07:00 +0000 (+0000) Subject: power: fix closing frequency file X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2414ce9b7b1770be2a5f406a1862589ebdef0315;p=dpdk.git power: fix closing frequency file 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") Signed-off-by: Anatoly Burakov Acked-by: Reshma Pattan --- 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';