Skip to content

Commit bd46cd0

Browse files
claudiubezneabebarino
authored andcommitted
clk: ti: clkctrl: check return value of kasprintf()
kasprintf() returns a pointer to dynamically allocated memory. Pointer could be NULL in case allocation fails. Check pointer validity. Identified with coccinelle (kmerr.cocci script). Fixes: 8520495 ("clk: ti: clkctrl: convert subclocks to use proper names also") Fixes: 6c30905 ("clk: ti: clkctrl: Fix hidden dependency to node name") Signed-off-by: Claudiu Beznea <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Tony Lindgren <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent b73ed98 commit bd46cd0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/clk/ti/clkctrl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ static const char * __init clkctrl_get_clock_name(struct device_node *np,
258258
if (clkctrl_name && !legacy_naming) {
259259
clock_name = kasprintf(GFP_KERNEL, "%s-clkctrl:%04x:%d",
260260
clkctrl_name, offset, index);
261+
if (!clock_name)
262+
return NULL;
263+
261264
strreplace(clock_name, '_', '-');
262265

263266
return clock_name;
@@ -586,6 +589,10 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
586589
if (clkctrl_name) {
587590
provider->clkdm_name = kasprintf(GFP_KERNEL,
588591
"%s_clkdm", clkctrl_name);
592+
if (!provider->clkdm_name) {
593+
kfree(provider);
594+
return;
595+
}
589596
goto clkdm_found;
590597
}
591598

0 commit comments

Comments
 (0)