Skip to contentSkip to conversation

cacheinfo: clear cache_leaves(cpu) in free_cache_attributes()

PATCH In review Xiongfeng Wang 2 participants 2 messages Jul 14, 2021 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cacheinfo: clear cache_leaves(cpu) in free_cache_attributes()

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().

---
v1 -> v2: Drop the Fixes tag as it doesn't fix anything in upstream.

---
 drivers/base/cacheinfo.c | 1 +
 1 file changed, 1 insertion(+)
drivers/base/cacheinfo.c +1 -0
index bfc0959..dad2962 100644
@@ -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)
Signature · 1 line
1.7.12.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Xiongfeng Wang

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().

--
Regards,
Sudeep