[PATCH] PCI: prevent down_read when pci_devices is empty
commitf8f47c1bd192ef079131c01b6a2842d24e3a1b12
authorArd van Breemen <ard@telegraafnet.nl>
Thu, 11 Jan 2007 15:22:57 +0000 (11 10:22 -0500)
committerChris Wright <chrisw@sous-sol.org>
Mon, 5 Feb 2007 16:31:41 +0000 (5 08:31 -0800)
tree23ab2b65699bbf4a619316ab759c78b1f24ec739
parenta9281060e889df67249949013c22858135068738
[PATCH] PCI: prevent down_read when pci_devices is empty

The pci_find_subsys gets called very early by obsolete ide setup parameters.
This is a bogus call since pci is not initialized yet, so the list is empty.
But in the mean time, interrupts get enabled by down_read.  This can result in
a kernel panic when the irq controller gets initialized.

This patch checks if the device list is empty before taking the semaphore, and
hence will not enable irq's.  Furthermore it will inform that it is called
while pci_devices is empty as a reminder that the ide code needs to be fixed.

The pci_get_subsys can get called in the same manner, and as such is patched
in the same manner.

[akpm@osdl.org: cleanups]
Signed-off-by: Ard van Breemen <ard@telegraafnet.nl>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
[chrisw: fold in 6a4c24ec5212 to avoid printk spamming]
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
drivers/pci/search.c