lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <95773471-a94d-4c10-b678-2b5b702f3bed@web.de>
Date: Fri, 4 Oct 2024 16:47:04 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: linux-mtd@...ts.infradead.org, Miaoqian Lin <linmq006@...il.com>,
 Miquel Raynal <miquel.raynal@...tlin.com>, Rafał Miłecki
 <rafal@...ecki.pl>, Richard Weinberger <richard@....at>,
 Vignesh Raghavendra <vigneshr@...com>
Cc: LKML <linux-kernel@...r.kernel.org>, kernel-janitors@...r.kernel.org
Subject: [PATCH] mtd: parsers: ofpart: Use common of_node_put() code in
 bcm4908_partitions_fw_offset()

From: Markus Elfring <elfring@...rs.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@...rs.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ