mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/x86/intel-uncore-freq: Fail module load when plat_info is NULL
@ 2025-06-06 20:53 Srinivas Pandruvada
  2025-06-09  7:52 ` Ilpo Järvinen
  0 siblings, 1 reply; 2+ messages in thread
From: Srinivas Pandruvada @ 2025-06-06 20:53 UTC (permalink / raw)
  To: hdegoede, ilpo.jarvinen
  Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada,
	Dan Carpenter, stable

Address a Smatch static checker warning regarding an unchecked
dereference in the function call:
set_cdie_id(i, cluster_info, plat_info)
when plat_info is NULL.

Instead of addressing this one case, in general if plat_info is NULL
then it can cause other issues. For example in a two package system it
will give warning for duplicate sysfs entry as package ID will be always
zero for both packages when creating string for attribute group name.

plat_info is derived from TPMI ID TPMI_BUS_INFO, which is integral to
the core TPMI design. Therefore, it should not be NULL on a production
platform. Consequently, the module should fail to load if plat_info is
NULL.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/platform-driver-x86/aEKvGCLd1qmX04Tc@stanley.mountain/T/#u
Fixes: 8a54e2253e4c ("platform/x86/intel-uncore-freq: Uncore frequency control via TPMI")
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: stable@vger.kernel.org
---
 .../x86/intel/uncore-frequency/uncore-frequency-tpmi.c   | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

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 1c7b2f2716ca..44d9948ed224 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
@@ -511,10 +511,13 @@ static int uncore_probe(struct auxiliary_device *auxdev, const struct auxiliary_
 
 	/* Get the package ID from the TPMI core */
 	plat_info = tpmi_get_platform_data(auxdev);
-	if (plat_info)
-		pkg = plat_info->package_id;
-	else
+	if (unlikely(!plat_info)) {
 		dev_info(&auxdev->dev, "Platform information is NULL\n");
+		ret = -ENODEV;
+		goto err_rem_common;
+	}
+
+	pkg = plat_info->package_id;
 
 	for (i = 0; i < num_resources; ++i) {
 		struct tpmi_uncore_power_domain_info *pd_info;
-- 
2.49.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] platform/x86/intel-uncore-freq: Fail module load when plat_info is NULL
  2025-06-06 20:53 [PATCH] platform/x86/intel-uncore-freq: Fail module load when plat_info is NULL Srinivas Pandruvada
@ 2025-06-09  7:52 ` Ilpo Järvinen
  0 siblings, 0 replies; 2+ messages in thread
From: Ilpo Järvinen @ 2025-06-09  7:52 UTC (permalink / raw)
  To: hdegoede, Srinivas Pandruvada
  Cc: platform-driver-x86, linux-kernel, Dan Carpenter, stable

On Fri, 06 Jun 2025 13:53:00 -0700, Srinivas Pandruvada wrote:

> Address a Smatch static checker warning regarding an unchecked
> dereference in the function call:
> set_cdie_id(i, cluster_info, plat_info)
> when plat_info is NULL.
> 
> Instead of addressing this one case, in general if plat_info is NULL
> then it can cause other issues. For example in a two package system it
> will give warning for duplicate sysfs entry as package ID will be always
> zero for both packages when creating string for attribute group name.
> 
> [...]


Thank you for your contribution, it has been applied to my local
review-ilpo-fixes branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/1] platform/x86/intel-uncore-freq: Fail module load when plat_info is NULL
      commit: 685f88c72a0c4d12d3bd2ff50286938f14486f85

--
 i.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-06-09  7:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-06 20:53 [PATCH] platform/x86/intel-uncore-freq: Fail module load when plat_info is NULL Srinivas Pandruvada
2025-06-09  7:52 ` Ilpo Järvinen

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®