From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796327752; b=v40ECM/P5borgnKOQgMOON14IvjESgQE0RGpXPV9J4VXaVV5XhIOVJbZvZUMV0RKsixX MSRyBFqIM5moXvFhrVZX8FqFCa33fAU+U2j+b0WgxnG34+gveTXpWq2ChCnwC252QmCEO cEewaj8EFGBJa2PAN80yFkUBK6k16+amL/HxxZKBhPAydD8+JTZqrfVZyiBOuaYELhtgD jsm50b8CScOEWV+o69LmaNXFaRD4DKI+DbXXfpWOReyYWWqgv1zr5wpz8hfU8Y0JPrJ4z 3vs2nxk9ImQJUO7kyoLvI7jRADHKfxHP7CZUMbrMiVJDfZkkfBd3Jq141mcyB9vU99A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796327752; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=l6eJEKuP14PnyJLir/kjwdtzkVfGjZzCtQcg2W3i+tU=; b=RchUialknksEB3ZPzSA2r1zQlafSrnf70NBH+pI2asXcVexFzQvUw/7wu9eh/XlE/y6S 9T8znR/j8UTk8rglH53IqAa4fm7YRigLwtduHM+HXI7DWQyPz9IvgxlrNOpzdtGGjWztM JVtpmMbBebV0cYw76lmlfGhAooG8/5IfS/d6OowfsDi9+b91PwV9075ytWfu6wuubsTVI zlfzqn8ZUzPl3c9skW2P2xhwWmkoru5oE2vEntGRzO/MkOMVa4esrCiG1oXmhVFYgUTHj SPZ16GvGBsv1WODsQtUf6nFkkugdqmxmA3wcM+i2l5cuUp6rZiXQzUHnravwVQ5basQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ci6HpW9e; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55F59606A322; Thu, 3 Dec 2026 19:55:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ci6HpW9e Received: by smtp.kernel.org (Postfix) with ESMTPSA id 412AB1F0092B; Thu, 3 Dec 2026 19:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796327752; bh=l6eJEKuP14PnyJLir/kjwdtzkVfGjZzCtQcg2W3i+tU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ci6HpW9ezhp2nli+ygq3V8FCYbzJOeUjENMv904A+5ekB/iL/wZF+/IpkvAVElpll Ba/D1tDoTpgcamo5/JaqWNxztaQgnTMhFl7FXMPuIFwL2OU1DFPIr8Xtc5YYJ6j0ef iBobuMOnpqPHEfvZuE9f2XxOyaKDcY/kAVRo2925EWqkknlmT4trxS7HDmzv8T5BWM WR6cKh67VHADHCj6yvIw4PssHvJn/pg7DpUxxuiNTOS3X9vw74EEl3WRhR2V5+k7rL bGZOef0pe6stOjNqjijyc5uTBY1N2LgYZEDM0oXqzmtSQMVsb0O8XHwrjxV341MjxC xD245WCkJXw+w== From: Lee Jones To: lee@kernel.org, "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Jez Ng , Aubrey Li , Ricardo Neri , Len Brown , 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 Message-ID: <20261203195529.3063246-3-lee@kernel.org> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog In-Reply-To: <20261203195529.3063246-1-lee@kernel.org> References: <20261203195529.3063246-1-lee@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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