Catch various cases in libpayload where malloc() or memalign() return NULL
Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Peter Stuge <peter@stuge.se> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4474 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
committed by
Stefan Reinauer
parent
131c0070a3
commit
5fe6e23c61
@ -33,14 +33,16 @@
|
||||
hci_t *usb_hcs = 0;
|
||||
|
||||
hci_t *
|
||||
new_controller ()
|
||||
new_controller (void)
|
||||
{
|
||||
hci_t *controller = malloc (sizeof (hci_t));
|
||||
|
||||
/* atomic */
|
||||
controller->next = usb_hcs;
|
||||
usb_hcs = controller;
|
||||
/* atomic end */
|
||||
if (controller) {
|
||||
/* atomic */
|
||||
controller->next = usb_hcs;
|
||||
usb_hcs = controller;
|
||||
/* atomic end */
|
||||
}
|
||||
|
||||
return controller;
|
||||
}
|
||||
@ -48,13 +50,13 @@ new_controller ()
|
||||
void
|
||||
detach_controller (hci_t *controller)
|
||||
{
|
||||
if (controller == 0)
|
||||
if (controller == NULL)
|
||||
return;
|
||||
if (usb_hcs == controller) {
|
||||
usb_hcs = controller->next;
|
||||
} else {
|
||||
hci_t *it = usb_hcs;
|
||||
while (it != 0) {
|
||||
while (it != NULL) {
|
||||
if (it->next == controller) {
|
||||
it->next = controller->next;
|
||||
return;
|
||||
@ -386,3 +388,10 @@ usb_attach_device(hci_t *controller, int hubaddress, int port, int lowspeed)
|
||||
newdev_t->init (newdev_t);
|
||||
return newdev;
|
||||
}
|
||||
|
||||
void
|
||||
usb_fatal (const char *message)
|
||||
{
|
||||
printf(message);
|
||||
for (;;) ;
|
||||
}
|
||||
|
Reference in New Issue
Block a user