[PATCH v2] clk: bcm: rpi: Add NULL check in raspberrypi_clk_register()
henry martin
bsdhenrymartin at gmail.com
Thu Apr 17 03:17:20 PDT 2025
> Just a note, please don't send new patch versions as a reply to older
> ones. This makes them harder to find.
Noted, thanks for the review! I'll make sure to send new patch versions as
separate emails in the future.
Regards,
Henry
Stefan Wahren <wahrenst at gmx.net> 于2025年4月17日周四 18:09写道:
>
> Am 02.04.25 um 04:05 schrieb Henry Martin:
> > 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: 93d2725affd6 ("clk: bcm: rpi: Discover the firmware clocks")
> > Signed-off-by: Henry Martin <bsdhenrymartin at gmail.com>
> > Reviewed-by: Dave Stevenson <dave.stevenson at raspberrypi.com>
> Reviewed-by: Stefan Wahren <wahrenst at gmx.net>
>
> Just a note, please don't send new patch versions as a reply to older
> ones. This makes them harder to find.
>
> Thanks
> > ---
> > V1 -> V2: Correct the commit hash in the Fixes: tag.
> >
> > drivers/clk/bcm/clk-raspberrypi.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
> > index 0e1fe3759530..720acc10f8aa 100644
> > --- a/drivers/clk/bcm/clk-raspberrypi.c
> > +++ b/drivers/clk/bcm/clk-raspberrypi.c
> > @@ -286,6 +286,8 @@ static struct clk_hw *raspberrypi_clk_register(struct raspberrypi_clk *rpi,
> > init.name = devm_kasprintf(rpi->dev, GFP_KERNEL,
> > "fw-clk-%s",
> > rpi_firmware_clk_names[id]);
> > + if (!init.name)
> > + return ERR_PTR(-ENOMEM);
> > init.ops = &raspberrypi_firmware_clk_ops;
> > init.flags = CLK_GET_RATE_NOCACHE;
> >
>
More information about the linux-arm-kernel
mailing list