arch_topology: Free ACPI SMT entries on lookup failure
Subsystems (2)
Sudeep Holla
maintainerPATCH 1/1 arch_topology: Free ACPI SMT entries on lookup failure
A later CPU can fail find_acpi_cpu_topology() after earlier threaded CPUs have populated hetero_cpu. Returning immediately leaks the stored cpu_smt_info objects and the XArray nodes.
Send the error through the existing cleanup and retain its return code. Only update the SMT thread count after a successful parse.
Reported-by Sashiko <[email protected]>
Fixes e6b18ebfaf63 ("arm64: topology: Support SMT control on ACPI based system")
Signed-off-by Sudeep Holla <[email protected]>
--- drivers/base/arch_topology.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/base/arch_topology.c +9 -5
@@ -860,7 +860,7 @@ __weak int __init parse_acpi_topology(void)struct cpu_smt_info *entry;struct xarray hetero_cpu;unsigned long hetero_id; -int cpu, topology_id; +int cpu, topology_id, ret =0 ;if (acpi_disabled)return 0 ;
@@ -869,8 +869,10 @@ __weak int __init parse_acpi_topology(void)for_each_possible_cpu (cpu) { topology_id =find_acpi_cpu_topology (cpu,0 ); -if (topology_id <0 ) -return topology_id; +if (topology_id <0 ) { + ret = topology_id; + goto out; + }if (acpi_cpu_is_threaded (cpu)) { cpu_topology[cpu].thread_id = topology_id;
@@ -914,6 +916,7 @@ __weak int __init parse_acpi_topology(void) cpu_topology[cpu].package_id = topology_id; } +out:/* * This is a short loop since the number of XArray elements is the * number of heterogeneous CPU clusters. On a homogeneous system
@@ -925,9 +928,10 @@ __weak int __init parse_acpi_topology(void)kfree (entry); } -cpu_smt_set_num_threads (max_smt_thread_num, max_smt_thread_num); +if (!ret) +cpu_smt_set_num_threads (max_smt_thread_num, max_smt_thread_num);xa_destroy (&hetero_cpu); -return 0 ; +return ret; }void __init init_cpu_topology (void )
Signature · 1 line
2.43.0