summaryrefslogtreecommitdiff
path: root/payloads/libpayload/drivers/usb/usbhub.c
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@coresystems.de>2009-07-31 11:39:55 +0000
committerStefan Reinauer <stepan@openbios.org>2009-07-31 11:39:55 +0000
commit5fe6e23c61bf1fde7a1a0568b38d32c4e625f0ef (patch)
tree74ab1bde640908166368985f9598517756df3199 /payloads/libpayload/drivers/usb/usbhub.c
parent131c0070a3b224e8ec2c817444f1ae4cf2419193 (diff)
downloadcoreboot-5fe6e23c61bf1fde7a1a0568b38d32c4e625f0ef.tar.xz
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/usbhub.c')
-rw-r--r--payloads/libpayload/drivers/usb/usbhub.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/payloads/libpayload/drivers/usb/usbhub.c b/payloads/libpayload/drivers/usb/usbhub.c
index 4625246e22..0a5d0ebcb5 100644
--- a/payloads/libpayload/drivers/usb/usbhub.c
+++ b/payloads/libpayload/drivers/usb/usbhub.c
@@ -128,6 +128,9 @@ usb_hub_init (usbdev_t *dev)
dev->data = malloc (sizeof (usbhub_inst_t));
+ if (!dev->data)
+ usb_fatal("Not enough memory for USB hub.\n");
+
HUB_INST (dev)->descriptor =
(hub_descriptor_t *) get_descriptor (dev,
gen_bmRequestType
@@ -137,6 +140,9 @@ usb_hub_init (usbdev_t *dev)
HUB_INST (dev)->num_ports = HUB_INST (dev)->descriptor->bNbrPorts;
HUB_INST (dev)->ports =
malloc (sizeof (int) * (HUB_INST (dev)->num_ports + 1));
+ if (! HUB_INST (dev)->ports)
+ usb_fatal("Not enough memory for USB hub ports.\n");
+
for (i = 1; i <= HUB_INST (dev)->num_ports; i++)
HUB_INST (dev)->ports[i] = -1;
for (i = 1; i <= HUB_INST (dev)->num_ports; i++)