* [PATCH] clk: bcm: rpi: Fix potential NULL pointer dereference
@ 2025-02-11 0:09 Chenyuan Yang
2025-02-11 4:08 ` Florian Fainelli
2025-02-11 6:06 ` Michal Swiatkowski
0 siblings, 2 replies; 3+ messages in thread
From: Chenyuan Yang @ 2025-02-11 0:09 UTC (permalink / raw)
To: mturquette, sboyd, florian.fainelli
Cc: bcm-kernel-feedback-list, richardcochran, dave.stevenson,
popcornmix, mripard, u.kleine-koenig, nathan, linux-clk,
linux-rpi-kernel, linux-arm-kernel, linux-kernel, netdev, zzjas98,
Chenyuan Yang
The `init.name` could be NULL. Add missing check in the
raspberrypi_clk_register().
This is similar to commit 3027e7b15b02
("ice: Fix some null pointer dereference issues in ice_ptp.c").
Besides, bcm2835_register_pll_divider() under the same directory also
has a very similar check.
Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
---
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;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: bcm: rpi: Fix potential NULL pointer dereference
2025-02-11 0:09 [PATCH] clk: bcm: rpi: Fix potential NULL pointer dereference Chenyuan Yang
@ 2025-02-11 4:08 ` Florian Fainelli
2025-02-11 6:06 ` Michal Swiatkowski
1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2025-02-11 4:08 UTC (permalink / raw)
To: Chenyuan Yang, mturquette, sboyd
Cc: bcm-kernel-feedback-list, richardcochran, dave.stevenson,
popcornmix, mripard, u.kleine-koenig, nathan, linux-clk,
linux-rpi-kernel, linux-arm-kernel, linux-kernel, netdev, zzjas98
On 2/10/2025 4:09 PM, Chenyuan Yang wrote:
> The `init.name` could be NULL. Add missing check in the
> raspberrypi_clk_register().
> This is similar to commit 3027e7b15b02
> ("ice: Fix some null pointer dereference issues in ice_ptp.c").
> Besides, bcm2835_register_pll_divider() under the same directory also
> has a very similar check.
>
> Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: bcm: rpi: Fix potential NULL pointer dereference
2025-02-11 0:09 [PATCH] clk: bcm: rpi: Fix potential NULL pointer dereference Chenyuan Yang
2025-02-11 4:08 ` Florian Fainelli
@ 2025-02-11 6:06 ` Michal Swiatkowski
1 sibling, 0 replies; 3+ messages in thread
From: Michal Swiatkowski @ 2025-02-11 6:06 UTC (permalink / raw)
To: Chenyuan Yang
Cc: mturquette, sboyd, florian.fainelli, bcm-kernel-feedback-list,
richardcochran, dave.stevenson, popcornmix, mripard,
u.kleine-koenig, nathan, linux-clk, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, netdev, zzjas98
On Mon, Feb 10, 2025 at 06:09:17PM -0600, Chenyuan Yang wrote:
> The `init.name` could be NULL. Add missing check in the
> raspberrypi_clk_register().
> This is similar to commit 3027e7b15b02
> ("ice: Fix some null pointer dereference issues in ice_ptp.c").
> Besides, bcm2835_register_pll_divider() under the same directory also
> has a very similar check.
>
> Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
> ---
> 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;
Thanks for the fix. There is a need for a fixes tag in case like that.
Please add it in commit message. Take a look here for example [1].
[1] https://lore.kernel.org/netdev/DM3PR11MB8736BC7EF3A66720427F3775ECF22@DM3PR11MB8736.namprd11.prod.outlook.com/T/#mbc8028620ecffb2f3a23c96130fe03708e679b25
Beside that:
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
>
> --
> 2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-11 6:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-11 0:09 [PATCH] clk: bcm: rpi: Fix potential NULL pointer dereference Chenyuan Yang
2025-02-11 4:08 ` Florian Fainelli
2025-02-11 6:06 ` Michal Swiatkowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).