From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, "Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>, Jez Ng <jez@sfcompute.com>,
Aubrey Li <aubrey.li@linux.intel.com>,
Ricardo Neri <ricardo.neri-calderon@linux.intel.com>,
Len Brown <len.brown@intel.com>,
linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH 02/10] thermal: intel: hfi: Publish hfi_instance only after successful initialisation
Date: Thu, 3 Dec 2026 19:54:13 +0000 [thread overview]
Message-ID: <20261203195529.3063246-3-lee@kernel.org> (raw)
In-Reply-To: <20261203195529.3063246-1-lee@kernel.org>
intel_hfi_online() stores hfi_instance in per-CPU hfi_cpu_info before
allocating hw_table and local_table, and fails to clear
hfi_instance->hw_table after free_pages_exact() when local_table
allocation fails. Because the thermal LVT is still unmasked,
intel_hfi_process_event() and hfi_syscore_resume() can then dereference
NULL or freed pointers.
Defer publishing info->hfi_instance until the instance has been fully
initialised, clear hfi_instance->hw_table after freeing it on error,
and check hfi_instance for NULL in hfi_syscore_resume().
Fixes: 2d74e6319abe ("thermal: intel: hfi: Handle CPU hotplug events")
Closes: https://sashiko.dev/#/bug/linux-02550489-11c2-419c-9a5f-9dfad590b556
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/thermal/intel/intel_hfi.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c
index 19355679c1df..79d06b510fdc 100644
--- a/drivers/thermal/intel/intel_hfi.c
+++ b/drivers/thermal/intel/intel_hfi.c
@@ -435,10 +435,7 @@ void intel_hfi_online(unsigned int cpu)
if (!hfi_instances)
return;
- /*
- * Link @cpu to the HFI instance of its package. It does not
- * matter whether the instance has been initialized.
- */
+ /* Find the HFI instance of @cpu's package. */
info = &per_cpu(hfi_cpu_info, cpu);
pkg_id = topology_logical_package_id(cpu);
hfi_instance = info->hfi_instance;
@@ -447,7 +444,6 @@ void intel_hfi_online(unsigned int cpu)
return;
hfi_instance = &hfi_instances[pkg_id];
- info->hfi_instance = hfi_instance;
}
init_hfi_cpu_index(info);
@@ -491,6 +487,7 @@ void intel_hfi_online(unsigned int cpu)
raw_spin_lock_init(&hfi_instance->event_lock);
enable:
+ info->hfi_instance = hfi_instance;
cpumask_set_cpu(cpu, hfi_instance->cpus);
/*
@@ -510,6 +507,7 @@ void intel_hfi_online(unsigned int cpu)
free_hw_table:
free_pages_exact(hfi_instance->hw_table,
hfi_features.nr_table_pages << PAGE_SHIFT);
+ hfi_instance->hw_table = NULL;
goto unlock;
}
@@ -621,7 +619,7 @@ static void hfi_syscore_resume(void *data)
struct hfi_instance *hfi_instance = info->hfi_instance;
/* No locking needed. There is no concurrency with CPU online. */
- if (hfi_clients_nr > 0)
+ if (hfi_instance && hfi_clients_nr > 0)
hfi_enable_instance(hfi_instance);
}
--
2.56.1.911.g883d8bcb20-goog
next prev parent reply other threads:[~2026-12-03 19:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261203195529.3063246-1-lee@kernel.org>
2026-12-03 19:54 ` [PATCH 01/10] thermal: intel: hfi: Pass byte size to alloc_pages_exact() and free_pages_exact() Lee Jones
2026-12-03 19:54 ` Lee Jones [this message]
2026-12-03 19:54 ` [PATCH 03/10] thermal: int3400: Clean up ODVP attributes after unregistering thermal zone Lee Jones
2026-12-03 19:54 ` [PATCH 04/10] thermal/drivers/qcom/tsens-v1: Validate sensor count before legacy calibration Lee Jones
2026-12-03 19:54 ` [PATCH 05/10] thermal/drivers/qcom/tsens: Bound sensor initialisation by num_sensors Lee Jones
2026-12-03 19:54 ` [PATCH 06/10] thermal/drivers/rcar: Free IRQs before cancelling delayed work on remove Lee Jones
2026-12-03 19:54 ` [PATCH 07/10] thermal/drivers/imx91: Acquire runtime PM reference in imx91_tmu_get_temp() Lee Jones
2026-12-03 19:54 ` [PATCH 08/10] tools/thermal/tmon: Open log file with O_NOFOLLOW before validating and truncating Lee Jones
2026-12-03 19:54 ` [PATCH 09/10] thermal/drivers/qcom/tsens: Drop __init from ops init callbacks Lee Jones
2026-12-03 19:54 ` [PATCH 10/10] thermal/drivers/imx91: Use pm_runtime_resume_and_get() in imx91_tmu_change_mode() Lee Jones
2026-12-03 20:21 ` Frank Li
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=20261203195529.3063246-3-lee@kernel.org \
--to=lee@kernel.org \
--cc=aubrey.li@linux.intel.com \
--cc=daniel.lezcano@kernel.org \
--cc=jez@sfcompute.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=ricardo.neri-calderon@linux.intel.com \
--cc=rui.zhang@intel.com \
--cc=stable@vger.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