[PATCH] clk: aspeed: ast2700: Add missing NULL pointer check for devm_kasprintf()

Felix Gu ustc.gu at gmail.com
Wed Feb 18 00:16:37 PST 2026


devm_kasprintf() can return NULL on memory allocation failure.

Check the return value and return -ENOMEM if allocation fails in
ast2700_soc_clk_probe().

Fixes: fdc1eb624ddc ("clk: aspeed: add AST2700 clock driver")
Signed-off-by: Felix Gu <ustc.gu at gmail.com>
---
 drivers/clk/aspeed/clk-ast2700.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/aspeed/clk-ast2700.c b/drivers/clk/aspeed/clk-ast2700.c
index bbb2b571eb72..011f8be03edc 100644
--- a/drivers/clk/aspeed/clk-ast2700.c
+++ b/drivers/clk/aspeed/clk-ast2700.c
@@ -901,6 +901,8 @@ static int ast2700_soc_clk_probe(struct platform_device *pdev)
 
 	clk_ctrl->clk_data = clk_data;
 	reset_name = devm_kasprintf(dev, GFP_KERNEL, "reset%d", clk_data->scu);
+	if (!reset_name)
+		return -ENOMEM;
 
 	clk_hw_data = devm_kzalloc(dev, struct_size(clk_hw_data, hws, clk_data->nr_clks),
 				   GFP_KERNEL);

---
base-commit: fe9e3edb6a215515d1148d32a5c445c5bdd7916f
change-id: 20260218-ast2700-6cf87db729f0

Best regards,
-- 
Felix Gu <ustc.gu at gmail.com>




More information about the linux-arm-kernel mailing list