From: Sudeep Holla <sudeep.holla@kernel.org>
To: driver-core@lists.linux.dev
Cc: Sudeep Holla <sudeep.holla@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH v4 2/4] arch_topology: Free ACPI SMT entries on lookup failure
Date: Wed, 11 Nov 2026 10:03:29 +0000 [thread overview]
Message-ID: <20261111100331.2945297-3-sudeep.holla@kernel.org> (raw)
In-Reply-To: <20261111100331.2945297-1-sudeep.holla@kernel.org>
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 <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-f41acdf3-9470-4de9-b497-d5de16c8e7e8
Fixes: e6b18ebfaf63 ("arm64: topology: Support SMT control on ACPI based system")
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
---
drivers/base/arch_topology.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 8ed29885dccf..eea4c4257d08 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -858,7 +858,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;
@@ -867,8 +867,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;
@@ -912,6 +914,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
@@ -923,9 +926,13 @@ __weak int __init parse_acpi_topology(void)
kfree(entry);
}
+ /* Reset max_smt_thread_num to 1 on failure like in parse_socket() */
+ if (ret)
+ max_smt_thread_num = 1;
+
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)
--
2.43.0
next prev parent reply other threads:[~2026-11-11 10:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 10:03 [PATCH v4 0/4] arch_topology: Bunch of error patch related fixes Sudeep Holla
2026-11-11 10:03 ` [PATCH v4 1/4] arch_topology: Reset SMT state when socket parsing fails Sudeep Holla
2026-11-11 10:03 ` Sudeep Holla [this message]
2026-11-11 10:03 ` [PATCH v4 3/4] arch_topology: Reset SMT state when topology is unavailable Sudeep Holla
2026-11-11 10:03 ` [PATCH v4 4/4] arch_topology: Avoid zero CPU capacity on parse failure Sudeep Holla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261111100331.2945297-3-sudeep.holla@kernel.org \
--to=sudeep.holla@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=sashiko-bot@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox