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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/a3dc82f0-7333-465d-85b4-8034b1591442@web.de
This commit is contained in:
Markus Elfring 2026-06-10 11:20:37 +02:00 committed by Daniel Lezcano
parent f4428025c8
commit 481860eba8

View File

@ -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;