thermal: gov_power_allocator: Use common error handling code in power_allocator_bind()
Subsystems (3)
PATCH 1/1 thermal: gov_power_allocator: Use common error handling code in power_allocator_bind()
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.
--- drivers/thermal/gov_power_allocator.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/thermal/gov_power_allocator.c +5 -6
@@ -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;
Signature · 1 line
2.54.0
Quoted 44 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 10 Jun 2026 11:20:37 +0200Adjust 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(-)drivers/thermal/gov_power_allocator.c +3
-5@@ -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;
drivers/thermal/gov_power_allocator.c static int power_allocator_bind(struct thermal_zone_device *tz) · line 752
Quoted 10 lines
drivers/thermal/gov_power_allocator.c +2
-1@@ -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;
LGTM. BTW, I like the 'free_power' label ;)
Daniel Lezcano
AppliedQuoted 10 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 10 Jun 2026 11:20:37 +0200Adjust 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]>---
Applied, thanks
The following commit has been merged into the thermal/linux-next branch of thermal:
The following commit has been merged into the thermal/linux-next branch of thermal:
Commit-ID: 481860eba83b3fe27ca9be6f7f5bb4c8febc6572 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//481860eba83b3fe27ca9be6f7f5bb4c8febc6572 Author: Markus Elfring <[email protected]> AuthorDate: Wed, 10 Jun 2026 11:20:37 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Tue, 13 Oct 2026 16:26:37 +02:00
thermal: gov_power_allocator: Use common error handling code in power_allocator_bind()
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.
--- drivers/thermal/gov_power_allocator.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/thermal/gov_power_allocator.c +5 -6
@@ -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;