power: fix P-state base frequency handling
Previous fix for base frequency handling in pstate mode introduced a couple of issues: - When base_frequency file does not exist, it simply bails out because of what appears to be accidental addition of FOPEN_OR_ERR_RET. This is incorrect, as absence of this file is not fatal and is in fact expected on kernel versions earlier than 5.3 - When base_frequency file does exist, it gets opened, but never gets closed, resulting in a resource leak Both issues also manifest themselves as Coverity defects (dead code, and a resource leak), so this fix addresses both. Coverity issue: 369693, 369694 Bugzilla ID: 668 Fixes: 4db9587bbf72 ("power: check sysfs base frequency") Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com> Acked-by: Reshma Pattan <reshma.pattan@intel.com>
This commit is contained in:
parent
aa9cb78f66
commit
8a5febaac4
@ -206,7 +206,6 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
|
||||
pi->lcore_id);
|
||||
|
||||
f_base = fopen(fullpath_base, "r");
|
||||
FOPEN_OR_ERR_RET(f_base, -1);
|
||||
if (f_base == NULL) {
|
||||
/* No sysfs base_frequency, that's OK, continue without */
|
||||
base_ratio = 0;
|
||||
@ -221,6 +220,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
|
||||
|
||||
base_ratio = strtoul(buf_base, NULL, POWER_CONVERT_TO_DECIMAL)
|
||||
/ BUS_FREQ;
|
||||
fclose(f_base);
|
||||
}
|
||||
|
||||
/* Add MSR read to detect turbo status */
|
||||
|
Loading…
x
Reference in New Issue
Block a user