public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] PCI Update for 2.6.2-rc2
Date: Thu, 29 Jan 2004 17:31:45 -0800	[thread overview]
Message-ID: <10754263054147@kroah.com> (raw)
In-Reply-To: <20040130012925.GA11727@kroah.com>

ChangeSet 1.1509, 2004/01/29 14:26:16-08:00, rmk+lkml@arm.linux.org.uk

[PATCH] Prevent PCI driver registration failure oopsing

Greg,

As discussed about six or so months ago, we agreed to hold off this
patch until fairly late, due to its ability to catch duplicate PCI
driver names.  Please note that I haven't attempted to reproduce the
problem with recent kernels, and that all ARM kernel patches released
since then have had this patch in.

I'm guessing this will actually be 2.6.1 material since it probably
doesn't show for PCI drivers which are part of the kernel tree.


If pci_register_driver fails, the register the PCI driver structure
will not be registered with the driver model.  pci_register_driver
returns with negative value, and we then attempt to unregister the
driver structure.  This leads to an oops in the driver model.

The driver model does not return the number of devices it successfully
bound the driver to, and neither does pci_register_driver() return
this information.

Therefore, all of the code below is redundant.

(There's a little redundancy left in drivers/pci/pci-driver.c but it
is harmless unlike this block.)


 include/linux/pci.h |   21 +--------------------
 1 files changed, 1 insertion(+), 20 deletions(-)


diff -Nru a/include/linux/pci.h b/include/linux/pci.h
--- a/include/linux/pci.h	Thu Jan 29 17:24:49 2004
+++ b/include/linux/pci.h	Thu Jan 29 17:24:49 2004
@@ -785,26 +785,7 @@
 {
 	int rc = pci_register_driver (drv);
 
-	if (rc > 0)
-		return 0;
-
-	/* iff CONFIG_HOTPLUG and built into kernel, we should
-	 * leave the driver around for future hotplug events.
-	 * For the module case, a hotplug daemon of some sort
-	 * should load a module in response to an insert event. */
-#if defined(CONFIG_HOTPLUG) && !defined(MODULE)
-	if (rc == 0)
-		return 0;
-#else
-	if (rc == 0)
-		rc = -ENODEV;		
-#endif
-
-	/* if we get here, we need to clean up pci driver instance
-	 * and return some sort of error */
-	pci_unregister_driver (drv);
-	
-	return rc;
+	return rc < 0 ? rc : 0;
 }
 
 /*


  reply	other threads:[~2004-01-30  1:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-30  1:29 [BK PATCH] PCI update for 2.6.2-rc2 Greg KH
2004-01-30  1:31 ` Greg KH [this message]
2004-01-30  1:31   ` [PATCH] PCI Update " Greg KH
2004-01-30  1:31     ` Greg KH
2004-01-30  1:31       ` Greg KH
2004-01-30  1:31         ` Greg KH
2004-01-30  1:31           ` Greg KH
2004-01-30  1:31             ` Greg KH
2004-01-30  1:31               ` Greg KH
2004-01-30  1:31                 ` Greg KH
2004-01-30  1:31                   ` Greg KH
2004-01-30  1:31                     ` Greg KH
2004-01-30  1:31                       ` Greg KH
2004-01-30  1:31                         ` Greg KH
2004-01-30  1:31                           ` Greg KH
2004-01-30  1:31                             ` Greg KH
2004-01-30  1:31                               ` Greg KH
2004-01-30 12:26                               ` Russell King
2004-01-31  0:23                                 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10754263054147@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox