diff options
Diffstat (limited to 'payloads/libpayload/drivers/usb/usbhub.c')
-rw-r--r-- | payloads/libpayload/drivers/usb/usbhub.c | 6 |
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++) |