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 <anatoly.burakov@intel.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
This commit is contained in:
Anatoly Burakov 2021-07-09 15:55:59 +00:00 committed by David Marchand
parent a03e4b62a7
commit 87fb608356

View File

@ -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;
}