cpufreq: imx6q: Fix the resource leak caused by incorrect error return
Subsystems (2)
PATCH v2 1/1 cpufreq: imx6q: Fix the resource leak caused by incorrect error return
Previous goto only handled the node reference, the opp table, regulator & clk resource also need to be free before error return.
--- drivers/cpufreq/imx6q-cpufreq.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/cpufreq/imx6q-cpufreq.c +7 -8
@@ -383,23 +383,22 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) goto put_reg; } +/* Because we have added the OPPs here, we must free them */ + free_opp = true; +if (of_machine_is_compatible ("fsl,imx6ul" ) ||of_machine_is_compatible ("fsl,imx6ull" )) { ret =imx6ul_opp_check_speed_grading (cpu_dev);if (ret) { -if (ret == -EPROBE_DEFER ) - goto put_node; - -dev_err (cpu_dev,"failed to read ocotp: %d\n" , - ret); - goto put_node; +if (ret != -EPROBE_DEFER ) +dev_err (cpu_dev,"failed to read ocotp: %d\n" , + ret); + goto out_free_opp; } }else {imx6q_opp_check_speed_grading (cpu_dev); } -/* Because we have added the OPPs here, we must free them */ - free_opp = true; num =dev_pm_opp_get_opp_count (cpu_dev);if (num <0 ) { ret = num;
Signature · 1 line
2.21.0
Quoted 4 lines · Jacky Bai
Previous goto only handled the node reference, the opp table, regulator & clk resource also need to be free before error return.
Fixes ddb64c5db3c (cpufreq: imx6q: fix possible object reference leak).
This should have been.
Auto configure it with following in .gitconfig
[pretty]
fixes = Fixes: %h (\"%s\") onelin = commit %h (\"%s\")
and then:
git log --pretty=fixes ddb64c5db3c
will generate it by itself.
Quoted 31 lines
Signed-off-by Jacky Bai <[email protected]>Reviewed-by Dong Aisheng <[email protected]>--- drivers/cpufreq/imx6q-cpufreq.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)drivers/cpufreq/imx6q-cpufreq.c +7
-6@@ -383,23 +383,22 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) goto put_reg; } +/* Because we have added the OPPs here, we must free them */ + free_opp = true; +if (of_machine_is_compatible ("fsl,imx6ul" ) ||of_machine_is_compatible ("fsl,imx6ull" )) { ret =imx6ul_opp_check_speed_grading (cpu_dev);if (ret) { -if (ret == -EPROBE_DEFER ) - goto put_node; - -dev_err (cpu_dev,"failed to read ocotp: %d\n" , - ret); - goto put_node; +if (ret != -EPROBE_DEFER ) +dev_err (cpu_dev,"failed to read ocotp: %d\n" , + ret); + goto out_free_opp;
drivers/cpufreq/imx6q-cpufreq.c static int imx6q_cpufreq_probe(struct platform_device *pdev) · line 404
Quoted 10 lines
drivers/cpufreq/imx6q-cpufreq.c +0
-2} }else {imx6q_opp_check_speed_grading (cpu_dev); } -/* Because we have added the OPPs here, we must free them */ - free_opp = true; num =dev_pm_opp_get_opp_count (cpu_dev);if (num <0 ) { ret = num;
@Rafael: This needs to go in 5.2 itself, can you queue it directly ?
Signature · 1 line
viresh
Quoted 13 lines · Viresh Kumar
Quoted 4 lines · Jacky Bai
Previous goto only handled the node reference, the opp table, regulator & clk resource also need to be free before error return.
Fixes ddb64c5db3c (cpufreq: imx6q: fix possible object reference leak).This should have been.
Fixes ddb64c5db3cc ("cpufreq: imx6q: fix possible object reference leak")Auto configure it with following in .gitconfig
[pretty]
Quoted 8 lines
fixes = Fixes: %h (\"%s\") onelin = commit %h (\"%s\")and then:
git log --pretty=fixes
ddb64c5db3cwill generate it by itself.
Just to add my color of the bikeshed, I have (among others):
[alias]
oneq = show -s --pretty='format:%h (\"%s\")'
in my ~/.gitconfig and can do:
$ git oneq ddb64c5db3c
ddb64c5db3cc ("cpufreq: imx6q: fix possible object reference leak")which is a bit shorter than Viresh's suggestion.
(Originally I had "one" without the quotes which I learned (IIRC) from the git mailing list. Instead of deviating from this I added 'q' for "quotes" to match the usual convention in kernel land.)
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Viresh Kumar
maintainerQuoted 7 lines · Uwe Kleine-König
Just to add my color of the bikeshed, I have (among others):
[alias]
oneq = show -s --pretty='format:%h (\"%s\")'in my ~/.gitconfig and can do:
Quoted 8 lines
$ git oneq ddb64c5db3c ddb64c5db3cc ("cpufreq: imx6q: fix possible object reference leak")which is a bit shorter than Viresh's suggestion.
(Originally I had "one" without the quotes which I learned (IIRC) from the git mailing list. Instead of deviating from this I added 'q' for "quotes" to match the usual convention in kernel land.)
I didn't tell that I also use some bash style aliases :)
$ alias glf alias glf='git log --pretty=fixes'
and so all I do is:
glf ddb64c5db3c
Thanks Uwe.
Signature · 1 line
viresh