Skip to contentSkip to conversation

char: mxser: call disable_pci_device() if pci_probe() failed

PATCH Superseded Kulikov Vasiliy 2 participants 2 messages Aug 6, 2010 – Aug 8, 2010

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/18 char: mxser: call disable_pci_device() if pci_probe() failed

Driver should call disable_pci_device() if it returns from pci_probe() with error. Also it must not be called if pci_request_region() fails as it means that somebody uses device resources and rules the device.

---
 drivers/char/mxser.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
drivers/char/mxser.c +8 -4
index 3fc89da..3680eda 100644
@@ -2564,8 +2564,11 @@ static int __devinit mxser_probe(struct pci_dev *pdev,
 	/* vector */
 	ioaddress = pci_resource_start(pdev, 3);
 	retval = pci_request_region(pdev, 3, "mxser(vector)");
-	if (retval)
-		goto err_relio;
+	if (retval) {
+		pci_release_region(pdev, 2);
+		brd->info = NULL;
+		goto err;
+	}
 	brd->vector = ioaddress;
 
 	/* irq */
@@ -2616,10 +2619,11 @@ static int __devinit mxser_probe(struct pci_dev *pdev,
 	pci_set_drvdata(pdev, brd);
 
 	return 0;
-err_relio:
-	pci_release_region(pdev, 2);
 err_null:
 	brd->info = NULL;
+	pci_release_region(pdev, 2);
+	pci_release_region(pdev, 3);
+	pci_disable_device(pdev);
 err:
 	return retval;
 #else
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 17 lines · Kulikov Vasiliy
drivers/char/mxser.c +5 -2
@@ -2564,8 +2564,11 @@ static int __devinit mxser_probe(struct pci_dev *pdev,
 	/* vector */
 	ioaddress = pci_resource_start(pdev, 3);
 	retval = pci_request_region(pdev, 3, "mxser(vector)");
-	if (retval)
-		goto err_relio;
+	if (retval) {
+		pci_release_region(pdev, 2);
+		brd->info = NULL;
+		goto err;
+	}
 	brd->vector = ioaddress;
 
 	/* irq */

drivers/char/mxser.c static int __devinit mxser_probe(struct pci_dev *pdev, · line 2626

Quoted 10 lines
drivers/char/mxser.c +3 -2
@@ -2616,10 +2619,11 @@ static int __devinit mxser_probe(struct pci_dev *pdev,
 	pci_set_drvdata(pdev, brd);
 
 	return 0;
-err_relio:
-	pci_release_region(pdev, 2);
 err_null:
 	brd->info = NULL;
+	pci_release_region(pdev, 2);
+	pci_release_region(pdev, 3);
+	pci_disable_device(pdev);

Why did you reorder this so that you cannot jump here from the fail path above?

thanks,

Signature · 1 line
js