diff options
author | Stefan Reinauer <stepan@coresystems.de> | 2009-07-31 11:39:55 +0000 |
---|---|---|
committer | Stefan Reinauer <stepan@openbios.org> | 2009-07-31 11:39:55 +0000 |
commit | 5fe6e23c61bf1fde7a1a0568b38d32c4e625f0ef (patch) | |
tree | 74ab1bde640908166368985f9598517756df3199 /payloads/libpayload/drivers/usb/usb.c | |
parent | 131c0070a3b224e8ec2c817444f1ae4cf2419193 (diff) |
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
Diffstat (limited to 'payloads/libpayload/drivers/usb/usb.c')
-rw-r--r-- | payloads/libpayload/drivers/usb/usb.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/payloads/libpayload/drivers/usb/usb.c b/payloads/libpayload/drivers/usb/usb.c index d536d31d86..25e80065d7 100644 --- a/payloads/libpayload/drivers/usb/usb.c +++ b/payloads/libpayload/drivers/usb/usb.c @@ -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 (;;) ; +} |