From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: hansg@kernel.org, ilpo.jarvinen@linux.intel.com
Cc: platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Subject: [PATCH 1/2] platform/x86/intel-uncore-freq: Don't remove entries which are not added
Date: Sat, 14 Nov 2026 17:49:47 -0800 [thread overview]
Message-ID: <20261115014948.2517688-2-srinivas.pandruvada@linux.intel.com> (raw)
In-Reply-To: <20261115014948.2517688-1-srinivas.pandruvada@linux.intel.com>
When uncore_probe() fails, remove_cluster_entries() removes the entries of
all clusters of every mapped power domain. But not all of them are added:
- When the allocation of cluster_infos fails, cluster_count is already
set. So remove_cluster_entries() dereferences the NULL cluster_infos.
- When uncore_freq_add_entry() fails for a cluster, this cluster and all
later clusters were not added. uncore_freq_remove_die_entry() still
removes their attribute group, which doesn't exist. As domain_id of
these clusters is not UNCORE_DOMAIN_ID_INVALID, it also frees their
seqnum_id with ida_free(). The seqnum_id is 0 from allocation, which
can be in use by an entry of another device.
Skip removing an entry in uncore_freq_remove_die_entry(), when it is not
valid, which means that it was not added or is already removed. Also
skip power domains without cluster_infos in remove_cluster_entries().
Fixes: 01c10f88c9b7 ("platform/x86/intel-uncore-freq: tpmi: Provide cluster level control")
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
.../x86/intel/uncore-frequency/uncore-frequency-common.c | 5 +++++
.../x86/intel/uncore-frequency/uncore-frequency-tpmi.c | 3 ++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
index 4bcafedf68ef..6051aa040abf 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
@@ -312,12 +312,17 @@ EXPORT_SYMBOL_NS_GPL(uncore_freq_add_entry, "INTEL_UNCORE_FREQUENCY");
void uncore_freq_remove_die_entry(struct uncore_data *data)
{
mutex_lock(&uncore_lock);
+ /* Nothing to remove, if the entry was not added or already removed */
+ if (!data->valid)
+ goto uncore_unlock;
+
delete_attr_group(data, data->name);
data->control_cpu = -1;
data->valid = false;
if (data->domain_id != UNCORE_DOMAIN_ID_INVALID)
ida_free(&intel_uncore_ida, data->seqnum_id);
+uncore_unlock:
mutex_unlock(&uncore_lock);
}
EXPORT_SYMBOL_NS_GPL(uncore_freq_remove_die_entry, "INTEL_UNCORE_FREQUENCY");
diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
index 753ddfe8c759..73e0b0a94eaf 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
@@ -524,7 +524,8 @@ static void remove_cluster_entries(struct tpmi_uncore_struct *tpmi_uncore)
int j;
pd_info = &tpmi_uncore->pd_info[i];
- if (!pd_info->uncore_base)
+ /* Probe may fail before cluster_infos is allocated */
+ if (!pd_info->uncore_base || !pd_info->cluster_infos)
continue;
for (j = 0; j < pd_info->cluster_count; ++j) {
--
2.55.0
next prev parent reply other threads:[~2026-11-15 1:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 1:49 [PATCH 0/2] platform/x86/intel-uncore-freq: Fix error handling Srinivas Pandruvada
2026-11-15 1:49 ` Srinivas Pandruvada [this message]
2026-11-15 1:49 ` [PATCH 2/2] platform/x86/intel-uncore-freq: Fix deadlock when removing attributes Srinivas Pandruvada
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=20261115014948.2517688-2-srinivas.pandruvada@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.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®