From: "Jason Zebchuk" <jason@consensys.com>
To: <mj@ucw.cz>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH] pci_do_scan_bus
Date: Tue, 13 Aug 2002 12:52:21 -0400 [thread overview]
Message-ID: <015401c242e9$cb8b4370$4902a8c0@consensys.com> (raw)
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
next reply other threads:[~2002-08-13 16:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-13 16:52 Jason Zebchuk [this message]
[not found] <mailman.1029261839.22627.linux-kernel2news@redhat.com>
2002-08-13 19:08 ` [PATCH] pci_do_scan_bus Pete Zaitcev
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='015401c242e9$cb8b4370$4902a8c0@consensys.com' \
--to=jason@consensys.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mj@ucw.cz \
/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