driver: pmc_atom: free pmc->regmap when pmc_setup_clks fails
PATCH v2 1/1 driver: pmc_atom: free pmc->regmap when pmc_setup_clks fails
Smatch reports:
drivers/platform/x86/pmc_atom.c:496pmc_setup_dev() warn: 'pmc->regmap' not released on lines: 496.
Fix this by deallocating pm->regmap when pmc_setup_clks fails.
--- drivers/platform/x86/pmc_atom.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/pmc_atom.c +3 -1
@@ -488,9 +488,11 @@ static int pmc_setup_dev(struct pci_dev *pdev, const struct pci_device_id *ent)/* Register platform clocks - PMC_PLT_CLK [0..5] */ ret =pmc_setup_clks (pdev, pmc->regmap, data); -if (ret) +if (ret) { +iounmap (pmc->regmap);dev_warn (&pdev->dev,"platform clocks register failed: %d\n" , ret); + } pmc->init = true;return ret;
Signature · 1 line
2.25.1
Quoted 10 lines · Dongliang Mu
Smatch reports:
drivers/platform/x86/pmc_atom.c:496pmc_setup_dev()warn: 'pmc->regmap' not released on lines: 496.Fix this by deallocating
pm->regmapwhenpmc_setup_clksfails.Fixes 282a4e4ce5f9("platform/x86: Enable Atom PMC platform clocks")Signed-off-by Dongliang Mu <[email protected]>---
It says v2 in the subject, what is in v2 exactly in comparison to v1?
...
drivers/platform/x86/pmc_atom.c static int pmc_setup_dev(struct pci_dev *pdev, const struct pci_device_id *ent) · line 494
Quoted 6 lines
drivers/platform/x86/pmc_atom.c +2
-1ret =pmc_setup_clks (pdev, pmc->regmap, data); -if (ret) +if (ret) { +iounmap (pmc->regmap);dev_warn (&pdev->dev,"platform clocks register failed: %d\n" , ret);
In this case it makes sense to move to
dev_err(&pdev->dev, "platform clocks register failed: %d\n", ret);
Quoted 1 line
drivers/platform/x86/pmc_atom.c +1
-0+ }
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 25 lines · Andy Shevchenko
Quoted 10 lines · Dongliang Mu
Smatch reports:
drivers/platform/x86/pmc_atom.c:496pmc_setup_dev()warn: 'pmc->regmap' not released on lines: 496.Fix this by deallocating
pm->regmapwhenpmc_setup_clksfails.Fixes 282a4e4ce5f9("platform/x86: Enable Atom PMC platform clocks")Signed-off-by Dongliang Mu <[email protected]>---
It says v2 in the subject, what is in v2 exactly in comparison to v1?
...
drivers/platform/x86/pmc_atom.c static int pmc_setup_dev(struct pci_dev *pdev, const struct pci_device_id *ent) · line 494
Quoted 6 lines
drivers/platform/x86/pmc_atom.c +2
-1ret =pmc_setup_clks (pdev, pmc->regmap, data); -if (ret) +if (ret) { +iounmap (pmc->regmap);dev_warn (&pdev->dev,"platform clocks register failed: %d\n" , ret);In this case it makes sense to move to
Quoted 3 lines
dev_err(&pdev->dev, "platform clocks register failed: %d\n", ret);drivers/platform/x86/pmc_atom.c static int pmc_setup_dev(struct pci_dev *pdev, const struct pci_device_id *ent) · line 495
Quoted 1 line
drivers/platform/x86/pmc_atom.c +1
-0+ }
Also, what about cleaning up debugfs?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Dongliang Mu
Smatch reports:
drivers/platform/x86/pmc_atom.c:496pmc_setup_dev()warn: 'pmc->regmap' not released on lines: 496.
Quoted 7 lines
Quoted 5 lines
Fix this by deallocating
pm->regmapwhenpmc_setup_clksfails.Fixes 282a4e4ce5f9("platform/x86: Enable Atom PMC platform clocks")Signed-off-by Dongliang Mu <[email protected]>---
It says v2 in the subject, what is in v2 exactly in comparison to v1?
Sorry to forget to add this information
v1->v2: move iounmap(pmc->regmap); from success path to the error handling code.
Quoted 21 lines
...
drivers/platform/x86/pmc_atom.c static int pmc_setup_dev(struct pci_dev *pdev, const struct pci_device_id *ent) · line 494
Quoted 6 lines
ret = pmc_setup_clks(pdev, pmc->regmap, data);drivers/platform/x86/pmc_atom.c +2
-1-if (ret) +if (ret) { +iounmap (pmc->regmap);dev_warn (&pdev->dev,"platform clocks register failed: %d\n" , ret);In this case it makes sense to move to
dev_err(&pdev->dev, "platform clocks register failed: %d\n", ret);Quoted 1 line
+ }
--
With Best Regards,
Andy Shevchenko
Andy Shevchenko
NAKQuoted 9 lines · Dongliang Mu
Smatch reports:
drivers/platform/x86/pmc_atom.c:496pmc_setup_dev()warn: 'pmc->regmap' not released on lines: 496.Fix this by deallocating
pm->regmapwhenpmc_setup_clksfails.Fixes 282a4e4ce5f9("platform/x86: Enable Atom PMC platform clocks")Signed-off-by Dongliang Mu <[email protected]>
Okay, this driver is two in one, i.e. library for PMC access and some other stuff. When you do iounmap() you ruin library routines with that.
So, my other comments are fine in general, but not applicable here.
NAK.
Signature · 2 lines
With Best Regards, Andy Shevchenko