* [PATCH] pci_do_scan_bus
@ 2002-08-13 16:52 Jason Zebchuk
0 siblings, 0 replies; 2+ messages in thread
From: Jason Zebchuk @ 2002-08-13 16:52 UTC (permalink / raw)
To: mj; +Cc: linux-kernel
Hi Martin,
I've run into a stack overflow problem during boot that is caused by the
pci subsystem. The function pci_do_scan_bus() puts a pci_dev on the stack,
and then indirectly calls itself recursively. While this doesn't usually
cause any problems, the stack will overflow when there are a large number of
cascaded pci buses.
This patch will fix the problem in the 2.5.30 kernel. I discovered the
problem in the 2.4.18 kernel, and for anyone who wants to patch that kernel,
the same patch will work if you change "probe.c" to "pci.c"
Thanks,
Jason Zebchuk
Consensys RAIDZONE
--- linux-2.5.30/drivers/pci/probe.c Thu Aug 1 17:16:10 2002
+++ linux/drivers/pci/probe.c Tue Aug 6 12:36:53 2002
@@ -497,23 +497,27 @@
{
unsigned int devfn, max, pass;
struct list_head *ln;
- struct pci_dev *dev, dev0;
+ struct pci_dev *dev, *dev0;
DBG("Scanning bus %02x\n", bus->number);
max = bus->secondary;
/* Create a device template */
- memset(&dev0, 0, sizeof(dev0));
- dev0.bus = bus;
- dev0.sysdata = bus->sysdata;
- dev0.dev.parent = bus->dev;
- dev0.dev.bus = &pci_bus_type;
+ dev0 = kmalloc(sizeof(struct pci_dev), GFP_ATOMIC);
+ if (dev0 == NULL)
+ BUG();
+ memset(dev0, 0, sizeof(dev0));
+ dev0->bus = bus;
+ dev0->sysdata = bus->sysdata;
+ dev0->dev.parent = bus->dev;
+ dev0->dev.bus = &pci_bus_type;
/* Go find them, Rover! */
for (devfn = 0; devfn < 0x100; devfn += 8) {
- dev0.devfn = devfn;
- pci_scan_slot(&dev0);
+ dev0->devfn = devfn;
+ pci_scan_slot(dev0);
}
+ kfree(dev0);
/*
* After performing arch-dependent fixup of the bus, look behind
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] pci_do_scan_bus
[not found] <mailman.1029261839.22627.linux-kernel2news@redhat.com>
@ 2002-08-13 19:08 ` Pete Zaitcev
0 siblings, 0 replies; 2+ messages in thread
From: Pete Zaitcev @ 2002-08-13 19:08 UTC (permalink / raw)
To: Jason Zebchuk; +Cc: linux-kernel
> --- linux-2.5.30/drivers/pci/probe.c Thu Aug 1 17:16:10 2002
> +++ linux/drivers/pci/probe.c Tue Aug 6 12:36:53 2002
> /* Create a device template */
> - memset(&dev0, 0, sizeof(dev0));
> - dev0.bus = bus;
> + dev0 = kmalloc(sizeof(struct pci_dev), GFP_ATOMIC);
> + if (dev0 == NULL)
> + BUG();
> + memset(dev0, 0, sizeof(dev0));
> + dev0->bus = bus;
Why is this atomic? I think we do not scan from interrupts,
only from init/swapper and insmod contexts.
-- Pete
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-08-13 19:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.1029261839.22627.linux-kernel2news@redhat.com>
2002-08-13 19:08 ` [PATCH] pci_do_scan_bus Pete Zaitcev
2002-08-13 16:52 Jason Zebchuk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox