diff mbox series

[1/2] clk: versatile: clk-icst: Return directly after a failed kasprintf() call in of_syscon_icst_setup()

Message ID be06e4cf-2e36-4884-bcd0-5d5eb5f191cd@web.de (mailing list archive)
State New, archived
Headers show
Series versatile clock: Adjustments for two function implementations | expand

Commit Message

Markus Elfring Jan. 17, 2024, 5:41 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 17 Jan 2024 18:06:55 +0100

The result from a call of the function “kasprintf” was passed to
a subsequent function call without checking for a null pointer before
(according to a memory allocation failure).
This issue was detected by using the Coccinelle software.

Thus return directly after a failed kasprintf() call.

Fixes: 1b2189f3aa50b ("clk: versatile: clk-icst: Ensure clock names are unique")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/clk/versatile/clk-icst.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--
2.43.0
diff mbox series

Patch

diff --git a/drivers/clk/versatile/clk-icst.c b/drivers/clk/versatile/clk-icst.c
index d5cb372f0901..c4cf50a48972 100644
--- a/drivers/clk/versatile/clk-icst.c
+++ b/drivers/clk/versatile/clk-icst.c
@@ -537,10 +537,12 @@  static void __init of_syscon_icst_setup(struct device_node *np)
 		return;
 	}

-	/* Parent clock name is not the same as node parent */
-	parent_name = of_clk_get_parent_name(np, 0);
 	name = kasprintf(GFP_KERNEL, "%pOFP", np);
+	if (!name)
+		return;

+	/* Parent clock name is not the same as node parent */
+	parent_name = of_clk_get_parent_name(np, 0);
 	regclk = icst_clk_setup(NULL, &icst_desc, name, parent_name, map, ctype);
 	if (IS_ERR(regclk)) {
 		pr_err("error setting up syscon ICST clock %s\n", name);