Skip to content

Commit

Permalink
cacheinfo: clear cache_leaves(cpu) in free_cache_attributes()
Browse files Browse the repository at this point in the history
On ARM64, when PPTT(Processor Properties Topology Table) is not
implemented in ACPI boot, we will goto 'free_ci' with the following
print:
  Unable to detect cache hierarchy for CPU 0

But some other codes may still use 'num_leaves' to iterate through the
'info_list', such as get_cpu_cacheinfo_id(). If 'info_list' is NULL , it
would crash. So clear 'num_leaves' in free_cache_attributes().

Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Link: https://lore.kernel.org/r/1626226375-58730-1-git-send-email-wangxiongfeng2@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Xiongfeng Wang authored and Greg Kroah-Hartman committed Jul 21, 2021
1 parent f04948d commit e022eac
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/base/cacheinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ static void free_cache_attributes(unsigned int cpu)

kfree(per_cpu_cacheinfo(cpu));
per_cpu_cacheinfo(cpu) = NULL;
cache_leaves(cpu) = 0;
}

int __weak init_cache_level(unsigned int cpu)
Expand Down

0 comments on commit e022eac

Please sign in to comment.