public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [soc/renesas] renesas-soc: Add error handling in renesas_soc_init
@ 2023-11-29 14:34 Haoran Liu
  2023-11-30  3:54 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Haoran Liu @ 2023-11-29 14:34 UTC (permalink / raw)
  To: geert+renesas; +Cc: magnus.damm, linux-renesas-soc, linux-kernel, Haoran Liu

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@163.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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-01  9:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-29 14:34 [PATCH] [soc/renesas] renesas-soc: Add error handling in renesas_soc_init Haoran Liu
2023-11-30  3:54 ` kernel test robot
2023-11-30 10:59 ` Geert Uytterhoeven
2023-12-01  9:14 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox