From: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
To: "Kristen Carlson Accardi" <kristen.c.accardi@intel.com>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] platform/x86/intel: power-domains: Handle failed init in tpmi_get_power_domain_mask()
Date: Thu, 24 Sep 2026 14:40:44 -0700 [thread overview]
Message-ID: <edcf0b3a043400ce40e1bd7841003f8319542407.camel@linux.intel.com> (raw)
In-Reply-To: <20260924193625.1830526-3-kristen.c.accardi@intel.com>
On Thu, 2026-09-24 at 12:36 -0700, Kristen Carlson Accardi wrote:
> tpmi_init() returns early on CPU models that are not in tpmi_cpu_ids,
> before tpmi_power_domain_mask is allocated. When the driver is built
> in, the exported tpmi_get_power_domain_mask() remains callable after
> the failed init. It returns NULL then only because it indexes the
> NULL
> array at offset 0 for the zeroed per-CPU data. If cpuhp_setup_state()
> fails, the error path frees the array but leaves the pointer set, so
> the helper would return a pointer into freed memory.
>
> Nothing in the tree calls tpmi_get_power_domain_mask() today, so this
> is hardening rather than a fix for a reachable bug. Return NULL when
> the array was not allocated, and clear the pointer wherever it is
> freed, as the previous patch does for domain_die_map.
>
> Assisted-by: LLM
> Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> drivers/platform/x86/intel/tpmi_power_domains.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/platform/x86/intel/tpmi_power_domains.c
> b/drivers/platform/x86/intel/tpmi_power_domains.c
> index ea51fc56297d..d89b9894c42a 100644
> --- a/drivers/platform/x86/intel/tpmi_power_domains.c
> +++ b/drivers/platform/x86/intel/tpmi_power_domains.c
> @@ -139,6 +139,13 @@ cpumask_t *tpmi_get_power_domain_mask(int
> cpu_no)
> cpumask_t *mask;
> int index;
>
> + /*
> + * When built in, this stays callable after tpmi_init()
> failed
> + * before allocating the array.
> + */
> + if (!tpmi_power_domain_mask)
> + return NULL;
> +
> if (cpu_no >= num_possible_cpus())
> return NULL;
>
> @@ -256,6 +263,7 @@ static int __init tpmi_init(void)
>
> free_domain_mask:
> kfree(tpmi_power_domain_mask);
> + tpmi_power_domain_mask = NULL;
>
> return ret;
> }
> @@ -265,6 +273,7 @@ static void __exit tpmi_exit(void)
> {
> cpuhp_remove_state(tpmi_hp_state);
> kfree(tpmi_power_domain_mask);
> + tpmi_power_domain_mask = NULL;
> kfree(domain_die_map);
> domain_die_map = NULL;
> }
prev parent reply other threads:[~2026-09-24 21:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 19:36 [PATCH 0/2] platform/x86/intel: power-domains: Handle failed tpmi_init() Kristen Carlson Accardi
2026-09-24 19:36 ` [PATCH 1/2] platform/x86/intel: power-domains: Handle failed init in tpmi_get_linux_die_id() Kristen Carlson Accardi
2026-09-24 21:39 ` srinivas pandruvada
2026-09-24 19:36 ` [PATCH 2/2] platform/x86/intel: power-domains: Handle failed init in tpmi_get_power_domain_mask() Kristen Carlson Accardi
2026-09-24 21:40 ` srinivas pandruvada [this message]
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=edcf0b3a043400ce40e1bd7841003f8319542407.camel@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=kristen.c.accardi@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@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
all inboxes | Powered by JetHome®