[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <5d15388eeb82aed7839b6d842c26168a935c915a.1501610760.git.sathyanarayanan.kuppuswamy@linux.intel.com>
Date: Tue, 1 Aug 2017 11:13:49 -0700
From: sathyanarayanan.kuppuswamy@...ux.intel.com
To: x86@...nel.org, mingo@...hat.com, qipeng.zha@...el.com,
hpa@...or.com, dvhart@...radead.org, tglx@...utronix.de,
andy@...radead.org
Cc: linux-kernel@...r.kernel.org, platform-driver-x86@...r.kernel.org,
sathyaosid@...il.com,
Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@...ux.intel.com>
Subject: [RFC v1 1/6] platform/x86: intel_pmc_ipc: Fix error handling in ipc_pci_probe()
From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@...ux.intel.com>
This patch adds proper error handling for failure cases in
ipc_pci_probe() function.
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@...ux.intel.com>
---
drivers/platform/x86/intel_pmc_ipc.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index bb792a5..7b65237 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -489,33 +489,46 @@ static int ipc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
ret = pci_enable_device(pdev);
if (ret)
- return ret;
+ goto release_device;
ret = pci_request_regions(pdev, "intel_pmc_ipc");
if (ret)
- return ret;
+ goto disable_device;
pci_resource = pci_resource_start(pdev, 0);
len = pci_resource_len(pdev, 0);
if (!pci_resource || !len) {
dev_err(&pdev->dev, "Failed to get resource\n");
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto free_pci_resources;
}
init_completion(&ipcdev.cmd_complete);
if (request_irq(pdev->irq, ioc, 0, "intel_pmc_ipc", &ipcdev)) {
dev_err(&pdev->dev, "Failed to request irq\n");
- return -EBUSY;
+ ret = -EBUSY;
+ goto free_pci_resources;
}
ipcdev.ipc_base = ioremap_nocache(pci_resource, len);
if (!ipcdev.ipc_base) {
dev_err(&pdev->dev, "Failed to ioremap ipc base\n");
- free_irq(pdev->irq, &ipcdev);
ret = -ENOMEM;
+ goto free_irq;
}
+ return 0;
+
+free_irq:
+ free_irq(pdev->irq, &ipcdev);
+free_pci_resources:
+ pci_release_regions(pdev);
+disable_device:
+ pci_disable_device(pdev);
+release_device:
+ pci_dev_put(pdev);
+
return ret;
}
--
2.7.4
Powered by blists - more mailing lists