Commit 7c5488f0 authored by Ivan Kokshaysky's avatar Ivan Kokshaysky Committed by Richard Henderson

[PATCH] fix PCI bridge swizzle on takara and eiger

This fixes NULL pointer dereference (bus->self) for PCI devices
on the root bus.

Ivan.
parent 85530b97
...@@ -194,13 +194,8 @@ eiger_swizzle(struct pci_dev *dev, u8 *pinp) ...@@ -194,13 +194,8 @@ eiger_swizzle(struct pci_dev *dev, u8 *pinp)
case 0x0f: bridge_count = 4; break; /* 4 */ 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); slot = PCI_SLOT(dev->devfn);
} else { while (dev->bus->self) {
/* Must be a card-based bridge. */
do {
/* Check for built-in bridges on hose 0. */ /* Check for built-in bridges on hose 0. */
if (hose->index == 0 if (hose->index == 0
&& (PCI_SLOT(dev->bus->self->devfn) && (PCI_SLOT(dev->bus->self->devfn)
...@@ -208,13 +203,11 @@ eiger_swizzle(struct pci_dev *dev, u8 *pinp) ...@@ -208,13 +203,11 @@ eiger_swizzle(struct pci_dev *dev, u8 *pinp)
slot = PCI_SLOT(dev->devfn); slot = PCI_SLOT(dev->devfn);
break; break;
} }
/* Must be a card-based bridge. */
pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn)); pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn));
/* Move up the chain of bridges. */ /* Move up the chain of bridges. */
dev = dev->bus->self; dev = dev->bus->self;
/* Slot of the next bridge. */
slot = PCI_SLOT(dev->devfn);
} while (dev->bus->self);
} }
*pinp = pin; *pinp = pin;
return slot; return slot;
......
...@@ -231,8 +231,12 @@ takara_swizzle(struct pci_dev *dev, u8 *pinp) ...@@ -231,8 +231,12 @@ takara_swizzle(struct pci_dev *dev, u8 *pinp)
int slot = PCI_SLOT(dev->devfn); int slot = PCI_SLOT(dev->devfn);
int pin = *pinp; int pin = *pinp;
unsigned int ctlreg = inl(0x500); 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. */ /* Check for built-in bridges. */
if (dev->bus->number != 0 if (dev->bus->number != 0
&& busslot > 16 && busslot > 16
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment