Skip to contentSkip to conversation

driver: pmc_atom: free pmc->regmap in pmc_setup_dev

PATCH In review Dongliang Mu 2 participants 3 messages Nov 30, 2021 – Dec 1, 2021 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver: pmc_atom: free pmc->regmap in pmc_setup_dev

Smatch reports:

drivers/platform/x86/pmc_atom.c:496
pmc_setup_dev() warn: 'pmc->regmap' not released on lines: 496.

Fix this by deallocating pm->regmap.

---
 drivers/platform/x86/pmc_atom.c | 1 +
 1 file changed, 1 insertion(+)
drivers/platform/x86/pmc_atom.c +1 -0
index a9d2a4b98e57..95ba108ed716 100644
@@ -492,6 +492,7 @@ static int pmc_setup_dev(struct pci_dev *pdev, const struct pci_device_id *ent)
 		dev_warn(&pdev->dev, "platform clocks register failed: %d\n",
 			 ret);
 
+	iounmap(pmc->regmap);
 	pmc->init = true;
 	return ret;
 }
Signature · 1 line
2.25.1
#1 lore raw
Quoted 18 lines · Dongliang Mu

Smatch reports:

drivers/platform/x86/pmc_atom.c:496
pmc_setup_dev() warn: 'pmc->regmap' not released on lines: 496.

Fix this by deallocating pm->regmap.

---
 drivers/platform/x86/pmc_atom.c | 1 +
 1 file changed, 1 insertion(+)
drivers/platform/x86/pmc_atom.c +0 -0
index a9d2a4b98e57..95ba108ed716 100644

drivers/platform/x86/pmc_atom.c static int pmc_setup_dev(struct pci_dev *pdev, const struct pci_device_id *ent) · line 495

Quoted 4 lines
drivers/platform/x86/pmc_atom.c +1 -0
@@ -492,6 +492,7 @@ static int pmc_setup_dev(struct pci_dev *pdev, const struct pci_device_id *ent)
 		dev_warn(&pdev->dev, "platform clocks register failed: %d\n",
 			 ret);
 
+	iounmap(pmc->regmap);

This releases it on the success path so it will break the driver.

regards,
dan carpenter

Quoted 5 lines
drivers/platform/x86/pmc_atom.c +0 -0
 	pmc->init = true;
 	return ret;
 }
Signature · 1 line
2.25.1
#2 lore raw
Quoted 23 lines · Dan Carpenter
Quoted 21 lines · Dongliang Mu

Smatch reports:

drivers/platform/x86/pmc_atom.c:496
pmc_setup_dev() warn: 'pmc->regmap' not released on lines: 496.

Fix this by deallocating pm->regmap.

---
 drivers/platform/x86/pmc_atom.c | 1 +
 1 file changed, 1 insertion(+)
drivers/platform/x86/pmc_atom.c +0 -0
index a9d2a4b98e57..95ba108ed716 100644
@@ -492,6 +492,7 @@ static int pmc_setup_dev(struct pci_dev *pdev, const struct pci_device_id *ent)
              dev_warn(&pdev->dev, "platform clocks register failed: %d\n",
                       ret);
 
Quoted 3 lines

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
+     iounmap(pmc->regmap);

This releases it on the success path so it will break the driver.

Yes. I should only deallocate it in the failure handling of pm_setup_clks. Will modify it in the v2 version.

Quoted 9 lines

regards,
dan carpenter

Quoted 5 lines
drivers/platform/x86/pmc_atom.c +0 -1
      pmc->init = true;
      return ret;
 }
--

2.25.1