Skip to content

Commit 36e4ef8

Browse files
claudiubezneabebarino
authored andcommitted
clk: si5341: check return value of {devm_}kasprintf()
{devm_}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: 3044a86 ("clk: Add Si5341/Si5340 driver") Signed-off-by: Claudiu Beznea <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 2560114 commit 36e4ef8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/clk/clk-si5341.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,10 @@ static int si5341_probe(struct i2c_client *client)
16971697
for (i = 0; i < data->num_synth; ++i) {
16981698
synth_clock_names[i] = devm_kasprintf(&client->dev, GFP_KERNEL,
16991699
"%s.N%u", client->dev.of_node->name, i);
1700+
if (!synth_clock_names[i]) {
1701+
err = -ENOMEM;
1702+
goto free_clk_names;
1703+
}
17001704
init.name = synth_clock_names[i];
17011705
data->synth[i].index = i;
17021706
data->synth[i].data = data;
@@ -1715,6 +1719,10 @@ static int si5341_probe(struct i2c_client *client)
17151719
for (i = 0; i < data->num_outputs; ++i) {
17161720
init.name = kasprintf(GFP_KERNEL, "%s.%d",
17171721
client->dev.of_node->name, i);
1722+
if (!init.name) {
1723+
err = -ENOMEM;
1724+
goto free_clk_names;
1725+
}
17181726
init.flags = config[i].synth_master ? CLK_SET_RATE_PARENT : 0;
17191727
data->clk[i].index = i;
17201728
data->clk[i].data = data;

0 commit comments

Comments
 (0)