Skip to contentSkip to conversation

platform/x86/intel: power-domains: Fix error code in tpmi_init()

PATCH In review Dan Carpenter 3 participants 3 messages Jun 6, 2025 – Jun 9, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86/intel: power-domains: Fix error code in tpmi_init()

Return -ENOMEM instead of success if kcalloc() fails.

Fixes e37be5d85c60 ("platform/x86/intel: power-domains: Add interface to get Linux die ID")
---
 drivers/platform/x86/intel/tpmi_power_domains.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/tpmi_power_domains.c +3 -1
index 0c5c88eb7baf..9d8247bb9cfa 100644
@@ -228,8 +228,10 @@ static int __init tpmi_init(void)
 
 	domain_die_map = kcalloc(size_mul(topology_max_packages(), MAX_POWER_DOMAINS),
 				 sizeof(*domain_die_map), GFP_KERNEL);
-	if (!domain_die_map)
+	if (!domain_die_map) {
+		ret = -ENOMEM;
 		goto free_domain_mask;
+	}
 
 	ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
 				"platform/x86/tpmi_power_domains:online",
Signature · 1 line
2.47.2
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dan Carpenter

Return -ENOMEM instead of success if kcalloc() fails.

Fixes e37be5d85c60 ("platform/x86/intel: power-domains: Add

interface to get Linux die ID")

Quoted 24 lines

---
 drivers/platform/x86/intel/tpmi_power_domains.c | 4 +++-

 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/tpmi_power_domains.c +0 -0
index 0c5c88eb7baf..9d8247bb9cfa 100644
@@ -228,8 +228,10 @@ static int __init tpmi_init(void)


  domain_die_map = kcalloc(size_mul(topology_max_packages(), MAX_POWER_DOMAINS),
  sizeof(*domain_die_map), GFP_KERNEL);

drivers/platform/x86/intel/tpmi_power_domains.c +2 -1
-	if (!domain_die_map)
+	if (!domain_die_map) {
+		ret = -ENOMEM;

  goto free_domain_mask;

drivers/platform/x86/intel/tpmi_power_domains.c +1 -0
+	}


  ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "platform/x86/tpmi_power_domains:onl ine",

maintainer
#2 lore raw
In reply to Dan Carpenter
Quoted 3 lines · Dan Carpenter

Return -ENOMEM instead of success if kcalloc() fails.

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: power-domains: Fix error code in tpmi_init()

      commit: 1d0a61940e22e165e6acc4a9c6fb26edbe69112e

--
i.