Skip to content

Commit 685f88c

Browse files
spandruvadaij-intel
authored andcommitted
platform/x86/intel-uncore-freq: Fail module load when plat_info is NULL
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 <[email protected]> Closes: https://lore.kernel.org/platform-driver-x86/[email protected]/T/#u Fixes: 8a54e22 ("platform/x86/intel-uncore-freq: Uncore frequency control via TPMI") Signed-off-by: Srinivas Pandruvada <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 5808c34 commit 685f88c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,13 @@ static int uncore_probe(struct auxiliary_device *auxdev, const struct auxiliary_
511511

512512
/* Get the package ID from the TPMI core */
513513
plat_info = tpmi_get_platform_data(auxdev);
514-
if (plat_info)
515-
pkg = plat_info->package_id;
516-
else
514+
if (unlikely(!plat_info)) {
517515
dev_info(&auxdev->dev, "Platform information is NULL\n");
516+
ret = -ENODEV;
517+
goto err_rem_common;
518+
}
519+
520+
pkg = plat_info->package_id;
518521

519522
for (i = 0; i < num_resources; ++i) {
520523
struct tpmi_uncore_power_domain_info *pd_info;

0 commit comments

Comments
 (0)