Add else branch to avoide fclose(NULL)

This fixes a potential NULL-pointer reference crash in case
cpu_file == NULL and pass NULL to fclose().

Test: mm -j 8
Change-Id: Ib3267676bea910533bd85ac2935efe02d361fc6b
This commit is contained in:
liuchao 2016-11-11 16:46:10 +08:00
parent 9fe1a712fb
commit df7d84a049

View file

@ -138,8 +138,9 @@ static ssize_t get_cpu_usages(thermal_module_t *module, cpu_usage_t *list) {
fclose(file);
fclose(cpu_file);
return errno ? -errno : -EIO;
} else {
fclose(cpu_file);
}
fclose(cpu_file);
if (list != NULL) {
list[size] = (cpu_usage_t) {