Fix the resource leaking issue
Coverity issue: 337668
Fixes:
b60fd5f8b1ce8f0a2c ("power: add bit for high frequency cores")
Signed-off-by: Liang Ma <liang.j.ma@intel.com>
Tested-by: David Hunt <david.hunt@intel.com>
char *s_base;
uint32_t base_ratio = 0;
uint64_t max_non_turbo = 0;
+ int ret_val = 0;
snprintf(fullpath_min, sizeof(fullpath_min), POWER_SYSFILE_MIN_FREQ,
pi->lcore_id);
/* Add MSR read to detect turbo status */
- if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0)
- return -1;
+ if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0) {
+ ret_val = -1;
+ goto out;
+ }
max_non_turbo = (max_non_turbo&NON_TURBO_MASK)>>NON_TURBO_OFFSET;
pi->core_base_freq = base_ratio * BUS_FREQ;
out:
- return 0;
+ if (f_base != NULL)
+ fclose(f_base);
+ return ret_val;
}
static int