return a proper error after the panic when no device is found, and avoid a leak. Shouldn't happen anyway, but doesn't hurt.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28803 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
8214934cdc
commit
7c9f1243c4
|
@ -119,14 +119,17 @@ pci_device_init_driver(device_node* node, void** _cookie)
|
||||||
&function, false) != B_OK)
|
&function, false) != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
|
PCIDev *dev = gPCI->FindDevice(domain, bus, deviceNumber, function);
|
||||||
|
if (dev == NULL) {
|
||||||
|
panic("device not found!\n");
|
||||||
|
return ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
pci_device* device = (pci_device*)malloc(sizeof(*device));
|
pci_device* device = (pci_device*)malloc(sizeof(*device));
|
||||||
if (device == NULL)
|
if (device == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
device->device = gPCI->FindDevice(domain, bus, deviceNumber, function);
|
device->device = dev;
|
||||||
if (device->device == NULL)
|
|
||||||
panic("device not found!\n");
|
|
||||||
|
|
||||||
device->node = node;
|
device->node = node;
|
||||||
|
|
||||||
*_cookie = device;
|
*_cookie = device;
|
||||||
|
|
Loading…
Reference in New Issue