* The bus value of child devices are not necessarily the same as the one of

the parent bus. It is possible that there are other busses below the root
  bus and we must therefore always iterate through the child devices when
  searching for a device with a bus unequal to our own. Otherwise devices for
  non-null busses could not be found which would lead to crashes in operations
  involving them.
* Adding a panic in case finding a device failed as this should clearly not
  happen.

This probably fixes bug #2293 and might affect #2284 too.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25867 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2008-06-08 19:57:44 +00:00
parent 631d09ac07
commit 9079144ace
2 changed files with 6 additions and 2 deletions
+3 -2
View File
@@ -1301,12 +1301,13 @@ PCIDev *
PCI::_FindDevice(PCIBus *current, int domain, uint8 bus, uint8 device,
uint8 function)
{
if (current->domain == domain && current->bus == bus) {
if (current->domain == domain) {
// search device on this bus
for (PCIDev *child = current->child; child != NULL;
child = child->next) {
if (child->device == device && child->function == function)
if (child->bus == bus && child->device == device
&& child->function == function)
return child;
if (child->child != NULL) {
@@ -124,6 +124,9 @@ pci_device_init_driver(device_node* node, void** _cookie)
return B_NO_MEMORY;
device->device = gPCI->FindDevice(domain, bus, deviceNumber, function);
if (device->device == NULL)
panic("device not found!\n");
device->node = node;
*_cookie = device;