Re: [PATCH] clk: zynq: Prevent null pointer dereference caused by kmalloc failure

Stephen Boyd
2024-02-28T23:07:07Z

Quoting Duoming Zhou (2024-02-13 23:33:18)
> diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
> index 7bdeaff2bfd..7621c2f0046 100644
> --- a/drivers/clk/zynq/clkc.c
> +++ b/drivers/clk/zynq/clkc.c
> @@ -427,7 +427,7 @@ static void __init zynq_clk_setup(struct device_node *np)
> SLCR_GEM1_CLK_CTRL, 0, 0, &gem1clk_lock);
>
> tmp = strlen("mio_clk_00x");
> - clk_name = kmalloc(tmp, GFP_KERNEL);
> + clk_name = kmalloc(tmp, GFP_KERNEL | __GFP_NOFAIL);

Just make a stack variable please. __GFP_NOFAIL is a bad code smell.

> for (i = 0; i < NUM_MIO_PINS; i++) {
> int idx;
>