mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-mtd@lists.infradead.org,
	"Miaoqian Lin" <linmq006@gmail.com>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"Rafał Miłecki" <rafal@milecki.pl>,
	"Richard Weinberger" <richard@nod.at>,
	"Vignesh Raghavendra" <vigneshr@ti.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] mtd: parsers: ofpart: Use common of_node_put() code in bcm4908_partitions_fw_offset()
Date: Fri, 4 Oct 2024 16:47:04 +0200	[thread overview]
Message-ID: <95773471-a94d-4c10-b678-2b5b702f3bed@web.de> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 4 Oct 2024 16:30:52 +0200

Enlarge the scope for the local variable “err” and add a label
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/mtd/parsers/ofpart_bcm4908.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/parsers/ofpart_bcm4908.c b/drivers/mtd/parsers/ofpart_bcm4908.c
index bb072a0940e4..f9caf4a44b4c 100644
--- a/drivers/mtd/parsers/ofpart_bcm4908.c
+++ b/drivers/mtd/parsers/ofpart_bcm4908.c
@@ -19,6 +19,7 @@ static long long bcm4908_partitions_fw_offset(void)
 	struct device_node *root;
 	struct property *prop;
 	const char *s;
+	int err;

 	root = of_find_node_by_path("/");
 	if (!root)
@@ -27,7 +28,6 @@ static long long bcm4908_partitions_fw_offset(void)
 	of_property_for_each_string(root, "brcm_blparms", prop, s) {
 		size_t len = strlen(BLPARAMS_FW_OFFSET);
 		unsigned long offset;
-		int err;

 		if (strncmp(s, BLPARAMS_FW_OFFSET, len) || s[len] != '=')
 			continue;
@@ -35,16 +35,17 @@ static long long bcm4908_partitions_fw_offset(void)
 		err = kstrtoul(s + len + 1, 0, &offset);
 		if (err) {
 			pr_err("failed to parse %s\n", s + len + 1);
-			of_node_put(root);
-			return err;
+			goto put_node;
 		}

 		of_node_put(root);
 		return offset << 10;
 	}

+	err = -ENOENT;
+put_node:
 	of_node_put(root);
-	return -ENOENT;
+	return err;
 }

 int bcm4908_partitions_post_parse(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts)
--
2.46.1


                 reply	other threads:[~2024-10-04 14:47 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=95773471-a94d-4c10-b678-2b5b702f3bed@web.de \
    --to=markus.elfring@web.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linmq006@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=rafal@milecki.pl \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.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®