Skip to content

Commit b73ed98

Browse files
claudiubezneabebarino
authored andcommitted
clk: keystone: sci-clk: 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: b745c07 ("clk: keystone: Add sci-clk driver support") Depends-on: 96488c0 ("clk: keystone: sci-clk: cut down the clock name length") Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Link: https://lore.kernel.org/r/20230530093913.1656095-7-claudiu.beznea@microchip.com Reviewed-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 267ad94 commit b73ed98

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/clk/keystone/sci-clk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ static int _sci_clk_build(struct sci_clk_provider *provider,
294294

295295
name = kasprintf(GFP_KERNEL, "clk:%d:%d", sci_clk->dev_id,
296296
sci_clk->clk_id);
297+
if (!name)
298+
return -ENOMEM;
297299

298300
init.name = name;
299301

0 commit comments

Comments
 (0)