lkml.org 
[lkml]   [2003]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] PCI fixes for 2.5.62
ChangeSet 1.1004, 2003/02/20 14:23:43-08:00, greg@kroah.com

[PATCH] PCI i386: remove large stack usage in pci_sanity_check()


diff -Nru a/arch/i386/pci/direct.c b/arch/i386/pci/direct.c
--- a/arch/i386/pci/direct.c Thu Feb 20 16:46:31 2003
+++ b/arch/i386/pci/direct.c Thu Feb 20 16:46:31 2003
@@ -196,21 +196,35 @@
static int __devinit pci_sanity_check(struct pci_ops *o)
{
u32 x = 0;
- struct pci_bus bus; /* Fake bus and device */
- struct pci_dev dev;
+ int retval = 0;
+ struct pci_bus *bus; /* Fake bus and device */
+ struct pci_dev *dev;

if (pci_probe & PCI_NO_CHECKS)
return 1;
- bus.number = 0;
- dev.bus = &bus;
- for(dev.devfn=0; dev.devfn < 0x100; dev.devfn++)
- if ((!o->read(&bus, dev.devfn, PCI_CLASS_DEVICE, 2, &x) &&
+
+ bus = kmalloc(sizeof(*bus), GFP_ATOMIC);
+ dev = kmalloc(sizeof(*dev), GFP_ATOMIC);
+ if (!bus || !dev) {
+ printk(KERN_ERR "Out of memory in %s\n", __FUNCTION__);
+ goto exit;
+ }
+
+ bus->number = 0;
+ dev->bus = bus;
+ for(dev->devfn=0; dev->devfn < 0x100; dev->devfn++)
+ if ((!o->read(bus, dev->devfn, PCI_CLASS_DEVICE, 2, &x) &&
(x == PCI_CLASS_BRIDGE_HOST || x == PCI_CLASS_DISPLAY_VGA)) ||
- (!o->read(&bus, dev.devfn, PCI_VENDOR_ID, 2, &x) &&
- (x == PCI_VENDOR_ID_INTEL || x == PCI_VENDOR_ID_COMPAQ)))
- return 1;
+ (!o->read(bus, dev->devfn, PCI_VENDOR_ID, 2, &x) &&
+ (x == PCI_VENDOR_ID_INTEL || x == PCI_VENDOR_ID_COMPAQ))) {
+ retval = 1;
+ goto exit;
+ }
DBG("PCI: Sanity check failed\n");
- return 0;
+exit:
+ kfree(dev);
+ kfree(bus);
+ return retval;
}

static int __init pci_direct_init(void)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:33    [W:0.788 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site