mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
clk: si5341: check return value of {devm_}kasprintf()
[ Upstream commit36e4ef8201] {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:3044a860fd("clk: Add Si5341/Si5340 driver") Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Link: https://lore.kernel.org/r/20230530093913.1656095-5-claudiu.beznea@microchip.com Signed-off-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
dc3eef6480
commit
dc8d0178d5
@@ -1685,6 +1685,10 @@ static int si5341_probe(struct i2c_client *client,
|
|||||||
for (i = 0; i < data->num_synth; ++i) {
|
for (i = 0; i < data->num_synth; ++i) {
|
||||||
synth_clock_names[i] = devm_kasprintf(&client->dev, GFP_KERNEL,
|
synth_clock_names[i] = devm_kasprintf(&client->dev, GFP_KERNEL,
|
||||||
"%s.N%u", client->dev.of_node->name, i);
|
"%s.N%u", client->dev.of_node->name, i);
|
||||||
|
if (!synth_clock_names[i]) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto free_clk_names;
|
||||||
|
}
|
||||||
init.name = synth_clock_names[i];
|
init.name = synth_clock_names[i];
|
||||||
data->synth[i].index = i;
|
data->synth[i].index = i;
|
||||||
data->synth[i].data = data;
|
data->synth[i].data = data;
|
||||||
@@ -1703,6 +1707,10 @@ static int si5341_probe(struct i2c_client *client,
|
|||||||
for (i = 0; i < data->num_outputs; ++i) {
|
for (i = 0; i < data->num_outputs; ++i) {
|
||||||
init.name = kasprintf(GFP_KERNEL, "%s.%d",
|
init.name = kasprintf(GFP_KERNEL, "%s.%d",
|
||||||
client->dev.of_node->name, i);
|
client->dev.of_node->name, i);
|
||||||
|
if (!init.name) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto free_clk_names;
|
||||||
|
}
|
||||||
init.flags = config[i].synth_master ? CLK_SET_RATE_PARENT : 0;
|
init.flags = config[i].synth_master ? CLK_SET_RATE_PARENT : 0;
|
||||||
data->clk[i].index = i;
|
data->clk[i].index = i;
|
||||||
data->clk[i].data = data;
|
data->clk[i].data = data;
|
||||||
|
|||||||
Reference in New Issue
Block a user