Skip to content

Commit bb7d09d

Browse files
claudiubezneabebarino
authored andcommitted
clk: cdce925: 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: 19fbbbb ("Add TI CDCE925 I2C controlled clock synthesizer driver") Depends-on: e665f02 ("clk: Convert to using %pOFn instead of device_node.name") Signed-off-by: Claudiu Beznea <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 144601f commit bb7d09d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/clk/clk-cdce925.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,10 @@ static int cdce925_probe(struct i2c_client *client)
701701
for (i = 0; i < data->chip_info->num_plls; ++i) {
702702
pll_clk_name[i] = kasprintf(GFP_KERNEL, "%pOFn.pll%d",
703703
client->dev.of_node, i);
704+
if (!pll_clk_name[i]) {
705+
err = -ENOMEM;
706+
goto error;
707+
}
704708
init.name = pll_clk_name[i];
705709
data->pll[i].chip = data;
706710
data->pll[i].hw.init = &init;
@@ -742,6 +746,10 @@ static int cdce925_probe(struct i2c_client *client)
742746
init.num_parents = 1;
743747
init.parent_names = &parent_name; /* Mux Y1 to input */
744748
init.name = kasprintf(GFP_KERNEL, "%pOFn.Y1", client->dev.of_node);
749+
if (!init.name) {
750+
err = -ENOMEM;
751+
goto error;
752+
}
745753
data->clk[0].chip = data;
746754
data->clk[0].hw.init = &init;
747755
data->clk[0].index = 0;
@@ -760,6 +768,10 @@ static int cdce925_probe(struct i2c_client *client)
760768
for (i = 1; i < data->chip_info->num_outputs; ++i) {
761769
init.name = kasprintf(GFP_KERNEL, "%pOFn.Y%d",
762770
client->dev.of_node, i+1);
771+
if (!init.name) {
772+
err = -ENOMEM;
773+
goto error;
774+
}
763775
data->clk[i].chip = data;
764776
data->clk[i].hw.init = &init;
765777
data->clk[i].index = i;

0 commit comments

Comments
 (0)