[dpdk-dev] [PATCH] power: fix use-after-free in pstate code
Burakov, Anatoly
anatoly.burakov at intel.com
Wed Apr 7 18:31:06 CEST 2021
On 07-Apr-21 4:56 PM, Anatoly Burakov wrote:
> Previous fix has addressed the incorrect handling of `base_frequency`
> file, but has added a use-after-free error due to the fact that all
> further code paths will lead to an `fclose()` call at the end, so the
> additional `fclose()` call right after processing the file was
> unnecessary.
>
> Coverity issue: 369901
>
> Fixes: 8a5febaac4f7 ("power: fix P-state base frequency handling")
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
> ---
Actually, self-nack, because this:
snprintf(fullpath_min, sizeof(fullpath_min), POWER_SYSFILE_MIN_FREQ,
pi->lcore_id);
f_min = fopen(fullpath_min, "rw+");
FOPEN_OR_ERR_RET(f_min, -1);
snprintf(fullpath_max, sizeof(fullpath_max), POWER_SYSFILE_MAX_FREQ,
pi->lcore_id);
f_max = fopen(fullpath_max, "rw+");
if (f_max == NULL)
fclose(f_min);
FOPEN_OR_ERR_RET(f_max, -1);
comes after, and will leak the f_base descriptor. Closing it and setting
it to NULL seems like a better solution.
--
Thanks,
Anatoly
More information about the dev
mailing list