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)
|
||||
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));
|
||||
if (device == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
device->device = gPCI->FindDevice(domain, bus, deviceNumber, function);
|
||||
if (device->device == NULL)
|
||||
panic("device not found!\n");
|
||||
|
||||
device->device = dev;
|
||||
device->node = node;
|
||||
|
||||
*_cookie = device;
|
||||
|
Loading…
x
Reference in New Issue
Block a user