Skip to contentSkip to conversation

pci: fix __pci_register_driver error handling

PATCH New Akinobu Mita 1 participant 1 message Oct 28, 2006 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci: fix __pci_register_driver error handling

__pci_register_driver() error path forgot to unwind. driver_unregister() needs to be called when pci_create_newid_file() failed.

Cc Greg Kroah-Hartman <[email protected]>
 drivers/pci/pci-driver.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/pci/pci-driver.c +5 -2
Index: work-fault-inject/drivers/pci/pci-driver.c
===================================================================
@@ -445,9 +445,12 @@ int __pci_register_driver(struct pci_dri
 
 	/* register with core */
 	error = driver_register(&drv->driver);
+	if (error)
+		return error;
 
-	if (!error)
-		error = pci_create_newid_file(drv);
+	error = pci_create_newid_file(drv);
+	if (error)
+		driver_unregister(&drv->driver);
 
 	return error;
 }