From 87fb60835641d790bb57b17043c565317395c119 Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Fri, 9 Jul 2021 15:55:59 +0000 Subject: [PATCH] power: fix crash on error for intel_pstate Currently, the error paths can lead to attempts at dereferencing NULL pointers. Add the check to avoid attempts at dereferencing NULL pointers. Coverity issue: 371895 Coverity issue: 371889 Fixes: 06cffd468fdd ("power: refactor ACPI and intel_pstate support") Signed-off-by: Anatoly Burakov Reviewed-by: David Marchand --- lib/power/power_pstate_cpufreq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c index ba28ddcfca..3b607515fd 100644 --- a/lib/power/power_pstate_cpufreq.c +++ b/lib/power/power_pstate_cpufreq.c @@ -440,8 +440,10 @@ power_get_available_freqs(struct pstate_power_info *pi) num_freqs, pi->lcore_id); out: - fclose(f_min); - fclose(f_max); + if (f_min != NULL) + fclose(f_min); + if (f_max != NULL) + fclose(f_max); return ret; } -- 2.20.1