Skip to content

Commit 13de464

Browse files
Henry Martinbebarino
authored andcommitted
clk: davinci: Add NULL check in davinci_lpsc_clk_register()
devm_kasprintf() returns NULL when memory allocation fails. Currently, davinci_lpsc_clk_register() does not check for this case, which results in a NULL pointer dereference. Add NULL check after devm_kasprintf() to prevent this issue and ensuring no resources are left allocated. Fixes: c6ed4d7 ("clk: davinci: New driver for davinci PSC clocks") Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com> Link: https://lore.kernel.org/r/20250401131341.26800-1-bsdhenrymartin@gmail.com Reviewed-by: David Lechner <david@lechnology.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 2c9891e commit 13de464

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/clk/davinci/psc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ davinci_lpsc_clk_register(struct device *dev, const char *name,
277277

278278
lpsc->pm_domain.name = devm_kasprintf(dev, GFP_KERNEL, "%s: %s",
279279
best_dev_name(dev), name);
280+
if (!lpsc->pm_domain.name) {
281+
clk_hw_unregister(&lpsc->hw);
282+
kfree(lpsc);
283+
return ERR_PTR(-ENOMEM);
284+
}
280285
lpsc->pm_domain.attach_dev = davinci_psc_genpd_attach_dev;
281286
lpsc->pm_domain.detach_dev = davinci_psc_genpd_detach_dev;
282287
lpsc->pm_domain.flags = GENPD_FLAG_PM_CLK;

0 commit comments

Comments
 (0)