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>] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 29 Nov 2023 06:34:31 -0800
From:   Haoran Liu <liuhaoran14@....com>
To:     geert+renesas@...der.be
Cc:     magnus.damm@...il.com, linux-renesas-soc@...r.kernel.org,
        linux-kernel@...r.kernel.org, Haoran Liu <liuhaoran14@....com>
Subject: [PATCH] [soc/renesas] renesas-soc: Add error handling in renesas_soc_init

This patch enhances the renesas_soc_init function in
drivers/soc/renesas/renesas-soc.c by adding error handling for the
of_property_read_string call. Previously, the function did not check
for failure cases of of_property_read_string, which could lead to
improper behavior if the required device tree properties were missing
or incorrect.

Although the error addressed by this patch may not occur in the current
environment, I still suggest implementing these error handling routines
if the function is not highly time-sensitive. As the environment evolves
or the code gets reused in different contexts, there's a possibility that
these errors might occur. Addressing them now can prevent potential
debugging efforts in the future, which could be quite resource-intensive.

Signed-off-by: Haoran Liu <liuhaoran14@....com>
---
 drivers/soc/renesas/renesas-soc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/renesas/renesas-soc.c b/drivers/soc/renesas/renesas-soc.c
index c732d4a5b26a..7a5f5c426118 100644
--- a/drivers/soc/renesas/renesas-soc.c
+++ b/drivers/soc/renesas/renesas-soc.c
@@ -487,7 +487,13 @@ static int __init renesas_soc_init(void)
 	}
 
 	np = of_find_node_by_path("/");
-	of_property_read_string(np, "model", &soc_dev_attr->machine);
+	ret = of_property_read_string(np, "model", &soc_dev_attr->machine);
+	if (ret) {
+		dev_err(dev, "Failed to read model property: %d\n", ret);
+		kfree(soc_dev_attr);
+		return ret;
+	}
+
 	of_node_put(np);
 
 	soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL);
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ