[v1,1/1] power: fix potential null dereferences
Checks
Commit Message
Currently, the error paths can lead to attempts at dereferencing NULL
pointers. Add the check to avoid attempts at dereferencing NULL
pointers.
Fixes: 06cffd468fdd ("power: refactor ACPI and intel_pstate support")
Cc: anatoly.burakov@intel.com
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
lib/power/power_pstate_cpufreq.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Comments
On Fri, Jul 9, 2021 at 5:02 PM Anatoly Burakov
<anatoly.burakov@intel.com> wrote:
>
> 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
> 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>
On 9/7/2021 4:09 PM, David Marchand wrote:
> On Fri, Jul 9, 2021 at 5:02 PM Anatoly Burakov
> <anatoly.burakov@intel.com> wrote:
>> 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
This patch also fixes
Coverity issue: 371889
Rgds,
Dave
>
>> 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>
>
>
@@ -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;
}