All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk/x86: pmc_atom: add kasprintf return value check
@ 2026-07-14  6:51 longlong yan
  2026-07-16 14:31 ` Brian Masney
  0 siblings, 1 reply; 2+ messages in thread
From: longlong yan @ 2026-07-14  6:51 UTC (permalink / raw)
  To: mturquette, sboyd, bmasney, linux-clk, linux-kernel; +Cc: longlong yan

The kasprintf() function returns NULL on memory allocation failure, but
the code in plt_clk_register() was not checking this return value. If
kasprintf fails, init.name would be NULL and could cause NULL pointer
dereference when clkdev_hw_create() uses it.

Add proper error checking for the kasprintf() return value and return
ERR_PTR(-ENOMEM) on failure.

Fixes: 1141d9d08184 ("clk: x86: Add Atom PMC platform clocks")
Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
---
 drivers/clk/x86/clk-pmc-atom.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/x86/clk-pmc-atom.c b/drivers/clk/x86/clk-pmc-atom.c
index 99291ba65da7..08c83e0abc41 100644
--- a/drivers/clk/x86/clk-pmc-atom.c
+++ b/drivers/clk/x86/clk-pmc-atom.c
@@ -160,6 +160,9 @@ static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id,
 		return ERR_PTR(-ENOMEM);
 
 	init.name =  kasprintf(GFP_KERNEL, "%s_%d", PLT_CLK_NAME_BASE, id);
+	if (!init.name)
+		return ERR_PTR(-ENOMEM);
+
 	init.ops = &plt_clk_ops;
 	init.flags = 0;
 	init.parent_names = parent_names;
-- 
2.43.0


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

end of thread, other threads:[~2026-07-16 14:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-14  6:51 [PATCH] clk/x86: pmc_atom: add kasprintf return value check longlong yan
2026-07-16 14:31 ` Brian Masney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.