* [PATCH] thermal: gov_power_allocator: Use common error handling code in power_allocator_bind()
@ 2026-06-10 9:30 Markus Elfring
2026-09-07 8:00 ` Lukasz Luba
0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-06-10 9:30 UTC (permalink / raw)
To: linux-pm, Daniel Lezcano, Lukasz Luba, Rafael J. Wysocki,
Zhang Rui
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] thermal: gov_power_allocator: Use common error handling code in power_allocator_bind()
2026-06-10 9:30 [PATCH] thermal: gov_power_allocator: Use common error handling code in power_allocator_bind() Markus Elfring
@ 2026-09-07 8:00 ` Lukasz Luba
0 siblings, 0 replies; 2+ messages in thread
From: Lukasz Luba @ 2026-09-07 8:00 UTC (permalink / raw)
To: Markus Elfring
Cc: LKML, linux-pm, Rafael J. Wysocki, kernel-janitors, Zhang Rui,
Daniel Lezcano
On 6/10/26 10:30, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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 <elfring@users.sourceforge.net>
> ---
> 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;
LGTM. BTW, I like the 'free_power' label ;)
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-07 8:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-10 9:30 [PATCH] thermal: gov_power_allocator: Use common error handling code in power_allocator_bind() Markus Elfring
2026-09-07 8:00 ` Lukasz Luba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox