[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241114091422.75412-1-hanchunchao@inspur.com>
Date: Thu, 14 Nov 2024 17:14:22 +0800
From: Charles Han <hanchunchao@...pur.com>
To: <david@...hnology.com>, <mturquette@...libre.com>, <sboyd@...nel.orgv>
CC: <linux-clk@...r.kernel.org>, <linux-kernel@...r.kernel.org>, Charles Han
<hanchunchao@...pur.com>
Subject: [PATCH] clk: davinci: Add NULL check in davinci_lpsc_clk_register
devm_kasprintf() can return a NULL pointer on failure,but this
returned value in davinci_lpsc_clk_register() is not checked.
Add NULL check in davinci_lpsc_clk_register(), to handle kernel NULL
pointer dereference error.
Fixes: c6ed4d734bc7 ("clk: davinci: New driver for davinci PSC clocks")
Signed-off-by: Charles Han <hanchunchao@...pur.com>
---
drivers/clk/davinci/psc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/clk/davinci/psc.c b/drivers/clk/davinci/psc.c
index 355d1be0b5d8..bc271ea72721 100644
--- a/drivers/clk/davinci/psc.c
+++ b/drivers/clk/davinci/psc.c
@@ -277,6 +277,9 @@ davinci_lpsc_clk_register(struct device *dev, const char *name,
lpsc->pm_domain.name = devm_kasprintf(dev, GFP_KERNEL, "%s: %s",
best_dev_name(dev), name);
+ if (!lpsc->pm_domain.name)
+ return -ENOMEM;
+
lpsc->pm_domain.attach_dev = davinci_psc_genpd_attach_dev;
lpsc->pm_domain.detach_dev = davinci_psc_genpd_detach_dev;
lpsc->pm_domain.flags = GENPD_FLAG_PM_CLK;
--
2.31.1
Powered by blists - more mailing lists