Skip to content

Commit 73c46d9

Browse files
Henry Martinbebarino
authored andcommitted
clk: bcm: rpi: Add NULL check in raspberrypi_clk_register()
devm_kasprintf() returns NULL when memory allocation fails. Currently, raspberrypi_clk_register() does not check for this case, which results in a NULL pointer dereference. Add NULL check after devm_kasprintf() to prevent this issue. Fixes: 93d2725 ("clk: bcm: rpi: Discover the firmware clocks") Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com> Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Link: https://lore.kernel.org/r/20250402020513.42628-1-bsdhenrymartin@gmail.com Reviewed-by: Stefan Wahren <wahrenst@gmx.net> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent d6fbdae commit 73c46d9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/clk/bcm/clk-raspberrypi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ static struct clk_hw *raspberrypi_clk_register(struct raspberrypi_clk *rpi,
286286
init.name = devm_kasprintf(rpi->dev, GFP_KERNEL,
287287
"fw-clk-%s",
288288
rpi_firmware_clk_names[id]);
289+
if (!init.name)
290+
return ERR_PTR(-ENOMEM);
289291
init.ops = &raspberrypi_firmware_clk_ops;
290292
init.flags = CLK_GET_RATE_NOCACHE;
291293

0 commit comments

Comments
 (0)