aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/search.c
diff options
context:
space:
mode:
authorArd van Breemen <ard@telegraafnet.nl>2007-01-05 19:36:21 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2007-01-06 02:55:21 -0500
commit6ae4adf50380d0fc5176a76d98d324f8fa491a8f (patch)
tree60607373a28073ce654e030545767e7c1062b98e /drivers/pci/search.c
parenta416aba637dcb4127595c02a59041cd278422f7e (diff)
[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>
Diffstat (limited to 'drivers/pci/search.c')
-rw-r--r--drivers/pci/search.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 45f2b20ef51..fab381ed853 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -193,6 +193,18 @@ static struct pci_dev * pci_find_subsys(unsigned int vendor,
193 struct pci_dev *dev; 193 struct pci_dev *dev;
194 194
195 WARN_ON(in_interrupt()); 195 WARN_ON(in_interrupt());
196
197 /*
198 * pci_find_subsys() can be called on the ide_setup() path, super-early
199 * in boot. But the down_read() will enable local interrupts, which
200 * can cause some machines to crash. So here we detect and flag that
201 * situation and bail out early.
202 */
203 if (unlikely(list_empty(&pci_devices))) {
204 printk(KERN_INFO "pci_find_subsys() called while pci_devices "
205 "is still empty\n");
206 return NULL;
207 }
196 down_read(&pci_bus_sem); 208 down_read(&pci_bus_sem);
197 n = from ? from->global_list.next : pci_devices.next; 209 n = from ? from->global_list.next : pci_devices.next;
198 210
@@ -259,6 +271,18 @@ pci_get_subsys(unsigned int vendor, unsigned int device,
259 struct pci_dev *dev; 271 struct pci_dev *dev;
260 272
261 WARN_ON(in_interrupt()); 273 WARN_ON(in_interrupt());
274
275 /*
276 * pci_get_subsys() can potentially be called by drivers super-early
277 * in boot. But the down_read() will enable local interrupts, which
278 * can cause some machines to crash. So here we detect and flag that
279 * situation and bail out early.
280 */
281 if (unlikely(list_empty(&pci_devices))) {
282 printk(KERN_NOTICE "pci_get_subsys() called while pci_devices "
283 "is still empty\n");
284 return NULL;
285 }
262 down_read(&pci_bus_sem); 286 down_read(&pci_bus_sem);
263 n = from ? from->global_list.next : pci_devices.next; 287 n = from ? from->global_list.next : pci_devices.next;
264 288