clk: raspberrypi: Handle cpufreq device registration failure
Subsystems (2)
PATCH 1/1 clk: raspberrypi: Handle cpufreq device registration failure
Check the return value of platform_device_register_data() when registering the raspberrypi-cpufreq device and propagate the error if registration fails.
This prevents the clock driver from reporting a successful probe when the cpufreq device could not be registered.
--- drivers/clk/bcm/clk-raspberrypi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/bcm/clk-raspberrypi.c +2 -0
@@ -553,6 +553,8 @@ static int raspberrypi_clk_probe(struct platform_device *pdev) rpi->cpufreq =platform_device_register_data (dev,"raspberrypi-cpufreq" ,-1 ,NULL ,0 ); +if (IS_ERR (rpi->cpufreq)) +return PTR_ERR (rpi->cpufreq);return 0 ; }
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] clk: raspberrypi: core clock probe fails if optional cpufreq device fails --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] clk: raspberrypi: core clock probe fails if optional cpufreq device fails --
commit 9a3a7cc11a038dd3ae191483f044c2febc6c2ed1
Author: Triet Hoang <[email protected]>
clk: raspberrypi: Handle cpufreq device registration failure
This commit adds an error check when registering the raspberrypi-cpufreq device in the clock driver probe function. It propagates the error if the cpufreq device fails to register, preventing a successful probe return.
drivers/clk/bcm/clk-raspberrypi.c static int raspberrypi_clk_probe(struct platform_device *pdev) · line 557
Quoted 10 lines
drivers/clk/bcm/clk-raspberrypi.c +2
-0@@ -553,6 +553,8 @@ static int raspberrypi_clk_probe(struct platform_device *pdev) rpi->cpufreq =platform_device_register_data (dev,"raspberrypi-cpufreq" ,-1 ,NULL ,0 ); +if (IS_ERR (rpi->cpufreq)) +return PTR_ERR (rpi->cpufreq);
[Severity: Medium]
Does this introduce a regression where fundamental core clocks might be unregistered if the optional cpufreq device fails?
The raspberrypi-clk driver provides essential system clocks, such as arm, core, and pixel. By returning an error from raspberrypi_clk_probe(), devres will automatically unregister these clocks. This can prevent other fundamental SoC devices that depend on these clocks from probing, which could severely degrade the system or prevent it from booting entirely.
Is it safe to structurally tie the survival of the core clocks to an optional dynamic frequency scaling child device?
Quoted 3 lines
drivers/clk/bcm/clk-raspberrypi.c +0
-0return 0 ; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Hi Triet,
nice catch.
Am 18.09.26 um 06:41 schrieb Triet Hoang:
Quoted 8 lines
Check the return value of
platform_device_register_data()when registering the raspberrypi-cpufreq device and propagate the error if registration fails.This prevents the clock driver from reporting a successful probe when the cpufreq device could not be registered.
Signed-off-by Triet Hoang <[email protected]>
Could you please add a Fixes tag?
Also it would be nice, if you can send a patch which also fixes drivers/firmware/raspberrypi.c
Thanks
Quoted 17 lines
--- drivers/clk/bcm/clk-raspberrypi.c | 2 ++ 1 file changed, 2 insertions(+)drivers/clk/bcm/clk-raspberrypi.c +2
-0@@ -553,6 +553,8 @@ static int raspberrypi_clk_probe(struct platform_device *pdev) rpi->cpufreq =platform_device_register_data (dev,"raspberrypi-cpufreq" ,-1 ,NULL ,0 ); +if (IS_ERR (rpi->cpufreq)) +return PTR_ERR (rpi->cpufreq);return 0 ; }
Quoted 8 lines · Triet Hoang
Check the return value of
platform_device_register_data()when registering the raspberrypi-cpufreq device and propagate the error if registration fails.This prevents the clock driver from reporting a successful probe when the cpufreq device could not be registered.
Signed-off-by Triet Hoang <[email protected]>
Brian Masney
AppliedQuoted 1 line · Triet Hoang
clk: raspberrypi: Handle cpufreq device registration failure
Applied, thanks!
[1/1] clk: raspberrypi: Handle cpufreq device registration failure
commit: e98e3d712023859af7cd78bb7fdb87ea3a9ffb83
Best regards,
Signature · 1 line
Brian Masney <[email protected]>