mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-pm@vger.kernel.org,
	Daniel Lezcano <daniel.lezcano@kernel.org>,
	Lukasz Luba <lukasz.luba@arm.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Zhang Rui <rui.zhang@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] thermal: gov_power_allocator: Use common error handling code in power_allocator_bind()
Date: Wed, 10 Jun 2026 11:30:26 +0200	[thread overview]
Message-ID: <a3dc82f0-7333-465d-85b4-8034b1591442@web.de> (raw)

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


             reply	other threads:[~2026-06-10  9:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-10  9:30 Markus Elfring [this message]
2026-09-07  8:00 ` Lukasz Luba
2026-09-28 16:41 ` Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a3dc82f0-7333-465d-85b4-8034b1591442@web.de \
    --to=markus.elfring@web.de \
    --cc=daniel.lezcano@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®