Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Julia Lawall <Julia.Lawall@inria.fr>, Nishanth Menon <nm@ti.com>,
	Santosh Shilimkar <ssantosh@kernel.org>,
	Tero Kristo <kristo@kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Cc: cocci@inria.fr, LKML <linux-kernel@vger.kernel.org>
Subject: [cocci] [PATCH] pmdomain: ti: Use common error handling code in ti_sci_pm_domain_probe()
Date: Sun, 5 Nov 2023 15:52:18 +0100	[thread overview]
Message-ID: <f6dddb61-e803-4930-885d-f353d9c7cc73@web.de> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 5 Nov 2023 15:30:28 +0100

Add a jump target so that a bit of exception handling can be better
reused at the end of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pmdomain/ti/ti_sci_pm_domains.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c
index c091d569ecd5..af8a1ed2db70 100644
--- a/drivers/pmdomain/ti/ti_sci_pm_domains.c
+++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c
@@ -153,18 +153,14 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
 					max_id = args.args[0];

 				pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
-				if (!pd) {
-					of_node_put(np);
-					return -ENOMEM;
-				}
+				if (!pd)
+					goto put_node;

 				pd->pd.name = devm_kasprintf(dev, GFP_KERNEL,
 							     "pd:%d",
 							     args.args[0]);
-				if (!pd->pd.name) {
-					of_node_put(np);
-					return -ENOMEM;
-				}
+				if (!pd->pd.name)
+					goto put_node;

 				pd->pd.power_off = ti_sci_pd_power_off;
 				pd->pd.power_on = ti_sci_pd_power_on;
@@ -193,6 +189,10 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
 		pd_provider->data.domains[pd->idx] = &pd->pd;

 	return of_genpd_add_provider_onecell(dev->of_node, &pd_provider->data);
+
+put_node:
+	of_node_put(np);
+	return -ENOMEM;
 }

 static struct platform_driver ti_sci_pm_domains_driver = {
--
2.42.0


                 reply	other threads:[~2023-11-05 14:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=f6dddb61-e803-4930-885d-f353d9c7cc73@web.de \
    --to=markus.elfring@web.de \
    --cc=Julia.Lawall@inria.fr \
    --cc=cocci@inria.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kristo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=ssantosh@kernel.org \
    --cc=ulf.hansson@linaro.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).