[PATCH] thermal: gov_power_allocator: Use common error handling code in power_allocator_bind()

Markus Elfring <[email protected]> Wed, 10 Jun 2026 11:30:26 +0200
Newsgroups org.kernel.vger.kernel-janitors,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pm
Message-ID <[email protected]>
From: Markus Elfring <[email protected]>
Date: Wed, 10 Jun 2026 11:20:37 +0200

Adjust labels so that a bit of exception handling can be better reused
at the end of this function implementation.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
---
 drivers/thermal/gov_power_allocator.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
index 37f2e22a999e..6b9450ffd5de 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -707,22 +707,20 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
 	ret = check_power_actors(tz, params);
 	if (ret < 0) {
 		dev_warn(&tz->device, "power_allocator: binding failed\n");
-		kfree(params);
-		return ret;
+		goto free_params;
 	}
 
 	ret = allocate_actors_buffer(params, ret);
 	if (ret) {
 		dev_warn(&tz->device, "power_allocator: allocation failed\n");
-		kfree(params);
-		return ret;
+		goto free_params;
 	}
 
 	if (!tz->tzp) {
 		tz->tzp = kzalloc_obj(*tz->tzp);
 		if (!tz->tzp) {
 			ret = -ENOMEM;
-			goto free_params;
+			goto free_power;
 		}
 
 		params->allocated_tzp = true;
@@ -746,8 +744,9 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
 
 	return 0;
 
-free_params:
+free_power:
 	kfree(params->power);
+free_params:
 	kfree(params);
 
 	return ret;
-- 
2.54.0