removed memory leaking when out of memory.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7733 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -123,8 +123,10 @@ init_driver(void)
|
|||||||
if (!item)
|
if (!item)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPci) < B_OK)
|
if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPci) < B_OK) {
|
||||||
|
free(item);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
for (cards = 0, index = 0; gPci->get_nth_pci_info(index++, item) == B_OK; ) {
|
for (cards = 0, index = 0; gPci->get_nth_pci_info(index++, item) == B_OK; ) {
|
||||||
const char *info = identify_device(item);
|
const char *info = identify_device(item);
|
||||||
@@ -138,7 +140,7 @@ init_driver(void)
|
|||||||
cards++;
|
cards++;
|
||||||
item = (pci_info *)malloc(sizeof(pci_info));
|
item = (pci_info *)malloc(sizeof(pci_info));
|
||||||
if (!item)
|
if (!item)
|
||||||
return B_OK; // already found 1 card, but out of memory
|
goto err_outofmem;
|
||||||
if (cards == MAX_CARDS)
|
if (cards == MAX_CARDS)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -167,6 +169,11 @@ err_mempool:
|
|||||||
terminate_timer();
|
terminate_timer();
|
||||||
err_timer:
|
err_timer:
|
||||||
err_cards:
|
err_cards:
|
||||||
|
err_outofmem:
|
||||||
|
for (index = 0; index < cards; index++) {
|
||||||
|
free(gDevList[index]);
|
||||||
|
free(gDevNameList[index]);
|
||||||
|
}
|
||||||
put_module(B_PCI_MODULE_NAME);
|
put_module(B_PCI_MODULE_NAME);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,8 +81,10 @@ init_driver(void)
|
|||||||
if (!item)
|
if (!item)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPci) < B_OK)
|
if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPci) < B_OK) {
|
||||||
|
free(item);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
for (cards = 0, index = 0; gPci->get_nth_pci_info(index++, item) == B_OK; ) {
|
for (cards = 0, index = 0; gPci->get_nth_pci_info(index++, item) == B_OK; ) {
|
||||||
if (item->vendor_id == 0x10ec && item->device_id == 0x8169) {
|
if (item->vendor_id == 0x10ec && item->device_id == 0x8169) {
|
||||||
@@ -94,7 +96,7 @@ init_driver(void)
|
|||||||
cards++;
|
cards++;
|
||||||
item = (pci_info *)malloc(sizeof(pci_info));
|
item = (pci_info *)malloc(sizeof(pci_info));
|
||||||
if (!item)
|
if (!item)
|
||||||
return B_OK; // already found 1 card, but out of memory
|
goto err_outofmem;
|
||||||
if (cards == MAX_CARDS)
|
if (cards == MAX_CARDS)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -116,6 +118,11 @@ init_driver(void)
|
|||||||
|
|
||||||
err_timer:
|
err_timer:
|
||||||
err_cards:
|
err_cards:
|
||||||
|
err_outofmem:
|
||||||
|
for (index = 0; index < cards; index++) {
|
||||||
|
free(gDevList[index]);
|
||||||
|
free(gDevNameList[index]);
|
||||||
|
}
|
||||||
put_module(B_PCI_MODULE_NAME);
|
put_module(B_PCI_MODULE_NAME);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user