bge: check that the bus is a pci bus before using it as such

This fixes the following panic on powerpc:
  pci_get_vendor failed for pcib1 on bus ofwbus0, error = 2

PR:		238730
Reported by:	Dennis Clarke <dclarke@blastwave.org>
Tested by:	Dennis Clarke <dclarke@blastwave.org>
MFC after:	2 weeks
This commit is contained in:
Andriy Gapon 2019-07-16 08:36:49 +00:00
parent 5eac9c1cb0
commit a70e114dc6

View File

@ -3276,6 +3276,8 @@ bge_mbox_reorder(struct bge_softc *sc)
bus = device_get_parent(dev); bus = device_get_parent(dev);
if (device_get_devclass(dev) != pcib) if (device_get_devclass(dev) != pcib)
break; break;
if (device_get_devclass(bus) != pci)
break;
for (i = 0; i < nitems(mbox_reorder_lists); i++) { for (i = 0; i < nitems(mbox_reorder_lists); i++) {
if (pci_get_vendor(dev) == if (pci_get_vendor(dev) ==
mbox_reorder_lists[i].vendor && mbox_reorder_lists[i].vendor &&
@ -3287,8 +3289,6 @@ bge_mbox_reorder(struct bge_softc *sc)
return (1); return (1);
} }
} }
if (device_get_devclass(bus) != pci)
break;
} }
return (0); return (0);
} }