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,27 +194,20 @@ eiger_swizzle(struct pci_dev *dev, u8 *pinp) ...@@ -194,27 +194,20 @@ 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. */ slot = PCI_SLOT(dev->devfn);
if (hose->index == 0 while (dev->bus->self) {
&& PCI_SLOT(dev->bus->self->devfn) > 20-bridge_count) { /* Check for built-in bridges on hose 0. */
slot = PCI_SLOT(dev->devfn); if (hose->index == 0
} else { && (PCI_SLOT(dev->bus->self->devfn)
/* Must be a card-based bridge. */ > 20 - bridge_count)) {
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); 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; *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