bus: qcom-ebi2: Fix clock leak on probe failure
Subsystems (2)
PATCH 1/1 bus: qcom-ebi2: Fix clock leak on probe failure
qcom_ebi2_probe() enables the EBI2X and EBI2 clocks before it walks child nodes and populates child devices. If reading a child node's reg property fails, or if of_platform_default_populate() fails, probe returns without disabling either clock.
Route those failure paths through the existing clock cleanup labels so a failed probe does not leave the clocks prepared and enabled.
---
This is a minimal error-path fix for a previously reported leak. A broader devm_clk_get_enabled() conversion was posted in 2023 and reviewed, and a similar cleanup was posted in 2024, but neither appears in current upstream:
https://lkml.iu.edu/hypermail/linux/kernel/2305.1/00605.html
https://lkml.iu.edu/2408.2/09536.html
drivers/bus/qcom-ebi2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/bus/qcom-ebi2.c +7 -3
@@ -353,7 +353,7 @@ static int qcom_ebi2_probe(struct platform_device *pdev)/* Figure out the chipselect */ ret =of_property_read_u32 (child,"reg" , &csindex);if (ret) -return ret; + goto err_disable_clk;if (csindex >5 ) { dev_err(dev,
@@ -372,8 +372,12 @@ static int qcom_ebi2_probe(struct platform_device *pdev) have_children = true; } -if (have_children) -return of_platform_default_populate (np,NULL , dev); +if (have_children) { + ret =of_platform_default_populate (np,NULL , dev); +if (ret) + goto err_disable_clk; + } +return 0 ; err_disable_clk:
Signature · 1 line
git 2.51.0
Quoted 8 lines · Ruoyu Wang
qcom_ebi2_probe()enables the EBI2X and EBI2 clocks before it walks child nodes and populates child devices. If reading a child node's reg property fails, or ifof_platform_default_populate()fails, probe returns without disabling either clock.Route those failure paths through the existing clock cleanup labels so a failed probe does not leave the clocks prepared and enabled.
Quoted 8 lines
Fixes 335a12754808 ("bus: qcom: add EBI2 driver")Signed-off-by Ruoyu Wang <[email protected]>---
This is a minimal error-path fix for a previously reported leak. A broaderdevm_clk_get_enabled()conversion was posted in 2023 and reviewed, and a similar cleanup was posted in 2024, but neither appears in current upstream:
https://lkml.iu.edu/hypermail/linux/kernel/2305.1/00605.html
https://lkml.iu.edu/2408.2/09536.html
Someone raised an identical patch last week
https://lore.kernel.org/linux-arm-msm/[email protected]/
Konrad
Quoted 18 lines · Konrad Dybcio
Quoted 8 lines · Ruoyu Wang
qcom_ebi2_probe()enables the EBI2X and EBI2 clocks before it walks child nodes and populates child devices. If reading a child node's reg property fails, or ifof_platform_default_populate()fails, probe returns without disabling either clock.Route those failure paths through the existing clock cleanup labels so a failed probe does not leave the clocks prepared and enabled.
Quoted 8 lines
Fixes 335a12754808 ("bus: qcom: add EBI2 driver")Signed-off-by Ruoyu Wang <[email protected]>---
This is a minimal error-path fix for a previously reported leak. A broaderdevm_clk_get_enabled()conversion was posted in 2023 and reviewed, and a similar cleanup was posted in 2024, but neither appears in current upstream:
https://lkml.iu.edu/hypermail/linux/kernel/2305.1/00605.html
https://lkml.iu.edu/2408.2/09536.html
Quoted 3 lines
Someone raised an identical patch last week
...in an obscure and seldom used driver.
So a clear sign that these reporters are using the same AI agent to find random bugs ;D
Yours,
Linus Walleij
Quoted 9 lines · Ruoyu Wang
qcom_ebi2_probe()enables the EBI2X and EBI2 clocks before it walks child nodes and populates child devices. If reading a child node's reg property fails, or ifof_platform_default_populate()fails, probe returns without disabling either clock.Route those failure paths through the existing clock cleanup labels so a failed probe does not leave the clocks prepared and enabled.
[...]
Applied, thanks!
[1/1] bus: qcom-ebi2: Fix clock leak on probe failure
commit: 64774dea58969194ea5c27fa639954e551a87024
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>