]> git.hungrycats.org Git - linux/commitdiff
[PATCH] fix PCI bridge swizzle on takara and eiger
authorIvan Kokshaysky <ink@jurassic.park.msu.ru>
Tue, 25 May 2004 01:44:10 +0000 (18:44 -0700)
committerRichard Henderson <rth@kanga.twiddle.home>
Tue, 25 May 2004 01:44:10 +0000 (18:44 -0700)
This fixes NULL pointer dereference (bus->self) for PCI devices
on the root bus.

Ivan.

arch/alpha/kernel/sys_eiger.c
arch/alpha/kernel/sys_takara.c

index 8e91eb6e46c0153b56527216fc5d7002977a193e..c6cbf47803a0dbbf4db0ff2a59b6c8eb8cda1aa5 100644 (file)
@@ -194,27 +194,20 @@ eiger_swizzle(struct pci_dev *dev, u8 *pinp)
           case 0x0f: bridge_count = 4; break; /* 4 */
        };
 
-       /*  Check first for the built-in bridges on hose 0. */
-       if (hose->index == 0
-           && PCI_SLOT(dev->bus->self->devfn) > 20-bridge_count) {
-               slot = PCI_SLOT(dev->devfn);
-       } else {
-               /* Must be a card-based bridge.  */
-               do {
-                       /* Check for built-in bridges on hose 0. */
-                       if (hose->index == 0
-                           && (PCI_SLOT(dev->bus->self->devfn)
-                               > 20 - bridge_count)) {
-                               slot = PCI_SLOT(dev->devfn);
-                               break;
-                       }
-                       pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn));
-
-                       /* Move up the chain of bridges.  */
-                       dev = dev->bus->self;
-                       /* Slot of the next bridge.  */
+       slot = PCI_SLOT(dev->devfn);
+       while (dev->bus->self) {
+               /* Check for built-in bridges on hose 0. */
+               if (hose->index == 0
+                   && (PCI_SLOT(dev->bus->self->devfn)
+                       > 20 - bridge_count)) {
                        slot = PCI_SLOT(dev->devfn);
-               } while (dev->bus->self);
+                       break;
+               }
+               /* Must be a card-based bridge.  */
+               pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn));
+
+               /* Move up the chain of bridges.  */
+               dev = dev->bus->self;
        }
        *pinp = pin;
        return slot;
index 24c255edad918b4b5a6dc826b617ccb19474b594..126c433a63ddcd9711e237b427f47fb29fa4f652 100644 (file)
@@ -231,8 +231,12 @@ takara_swizzle(struct pci_dev *dev, u8 *pinp)
        int slot = PCI_SLOT(dev->devfn);
        int pin = *pinp;
        unsigned int ctlreg = inl(0x500);
-       unsigned int busslot = PCI_SLOT(dev->bus->self->devfn);
+       unsigned int busslot;
 
+       if (!dev->bus->self)
+               return slot;
+
+       busslot = PCI_SLOT(dev->bus->self->devfn);
        /* Check for built-in bridges.  */
        if (dev->bus->number != 0
            && busslot > 16