Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1701320

[RFC v1 1/6] platform/x86: intel_pmc_ipc: Fix error handling in ipc_pci_probe()

From sathyanarayanan.kuppuswamy@linux.intel.com
Newsgroups linux.kernel
Subject [RFC v1 1/6] platform/x86: intel_pmc_ipc: Fix error handling in ipc_pci_probe()
Date 2017-08-01 20:20 +0200
Message-ID <u9JVU-7qE-33@gated-at.bofh.it> (permalink)
References <u9JVT-7qE-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>

This patch adds proper error handling for failure cases in
ipc_pci_probe() function.

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC v1 0/6] PMC/PUNIT IPC driver cleanup sathyanarayanan.kuppuswamy@linux.intel.com - 2017-08-01 20:20 +0200
  [RFC v1 1/6] platform/x86: intel_pmc_ipc: Fix error handling in ipc_pci_probe() sathyanarayanan.kuppuswamy@linux.intel.com - 2017-08-01 20:20 +0200
  [RFC v1 4/6] platform: x86: Add generic Intel IPC driver sathyanarayanan.kuppuswamy@linux.intel.com - 2017-08-01 20:20 +0200
  [RFC v1 2/6] platform/x86: intel_pmc_ipc: Use devm_* calls in driver probe sathyanarayanan.kuppuswamy@linux.intel.com - 2017-08-01 20:20 +0200
  [RFC v1 6/6] platform/x86: intel_pmc_ipc: Use generic Intel IPC device calls sathyanarayanan.kuppuswamy@linux.intel.com - 2017-08-01 20:20 +0200
  [RFC v1 5/6] platform/x86: intel_punit_ipc: Use generic intel ipc device calls sathyanarayanan.kuppuswamy@linux.intel.com - 2017-08-01 20:20 +0200
  Re: [RFC v1 0/6] PMC/PUNIT IPC driver cleanup Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-08-06 20:40 +0200

csiph-web