Re: [PATCH v2] clk: clk-loongson2: Fix the number count of clk provider

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Binbin Zhou (2025-01-09 03:30:04)
> diff --git a/drivers/clk/clk-loongson2.c b/drivers/clk/clk-loongson2.c
> index 6bf51d5a49a1..9c240a2308f5 100644
> --- a/drivers/clk/clk-loongson2.c
> +++ b/drivers/clk/clk-loongson2.c
> @@ -294,7 +294,7 @@ static int loongson2_clk_probe(struct platform_device *pdev)
>                 return -EINVAL;
>  
>         for (p = data; p->name; p++)
> -               clks_num++;
> +               clks_num = max(clks_num, p->id + 1);
>  
>         clp = devm_kzalloc(dev, struct_size(clp, clk_data.hws, clks_num),
>                            GFP_KERNEL);
> @@ -309,6 +309,9 @@ static int loongson2_clk_probe(struct platform_device *pdev)
>         clp->clk_data.num = clks_num;
>         clp->dev = dev;
>  
> +       /* Avoid returning NULL for unused id */
> +       memset_p((void **)&clp->clk_data.hws, ERR_PTR(-ENOENT), clks_num);

This looks wrong. It's already an array of pointers, i.e. the type is
'struct clk_hw *[]' or 'struct clk_hw **' so we shouldn't need to take
the address of it. Should it be

	memset_p((void **)clkp->clk_data.hws, ERR_PTR(-ENOENT), clks_num);

? It's unfortunate that we have to cast here, but I guess this is the
best way we can indicate that the type should be an array of pointers.





[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux