Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > fc11cd6e1c513a17304da94a5390f3cd > files > 2778

kernel-2.6.18-194.11.1.el5.src.rpm

From: Mark McLoughlin <markmc@redhat.com>
Date: Tue, 14 Apr 2009 18:44:00 +0100
Subject: [pci] fix __pci_register_driver error handling
Message-id: 1239731040.8530.94.camel@blaa
O-Subject: [RHEL5.4 PATCH 2/5] [pci] fix __pci_register_driver error handling
Bugzilla: 491842
RH-Acked-by: Prarit Bhargava <prarit@redhat.com>
RH-Acked-by: Don Dutile <ddutile@redhat.com>
RH-Acked-by: Chris Wright <chrisw@redhat.com>

https://bugzilla.redhat.com/491842

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

This is just a trival backport of a fix in order to ease
the backport of remove_id. The original commit is here:

  http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=50bf14b3ff

Signed-off-by: Mark McLoughlin <markmc@redhat.com>

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 474e9cd..930c1f8 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -391,9 +391,12 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner)
 
 	/* 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;
 }