mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mtd: parsers: ofpart: Use common of_node_put() code in bcm4908_partitions_fw_offset()
@ 2024-10-04 14:47 Markus Elfring
  0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2024-10-04 14:47 UTC (permalink / raw)
  To: linux-mtd, Miaoqian Lin, Miquel Raynal, Rafał Miłecki,
	Richard Weinberger, Vignesh Raghavendra
  Cc: LKML, kernel-janitors

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-10-04 14:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-04 14:47 [PATCH] mtd: parsers: ofpart: Use common of_node_put() code in bcm4908_partitions_fw_offset() Markus Elfring

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®