]> xenbits.xensource.com Git - seabios.git/commitdiff
xhci: Check if scratch pad allocation fails.
authorKevin O'Connor <kevin@koconnor.net>
Mon, 20 Jan 2014 16:46:16 +0000 (11:46 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 29 Jan 2014 17:57:01 +0000 (12:57 -0500)
Some boards ask for a large amount of ram for scratch pad usage, and
it is possible the allocation will fail.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/hw/usb-xhci.c

index dc54182927492416f76905f5a11647e5f9c85dae..65d1be0cfcdbcefae09bd690746eb0c175233efb 100644 (file)
@@ -687,6 +687,12 @@ configure_xhci(void *data)
         dprintf(3, "%s: setup %d scratch pad buffers\n", __func__, spb);
         u64 *spba = memalign_high(64, sizeof(*spba) * spb);
         void *pad = memalign_high(PAGE_SIZE, PAGE_SIZE * spb);
+        if (!spba || !pad) {
+            warn_noalloc();
+            free(spba);
+            free(pad);
+            goto fail;
+        }
         int i;
         for (i = 0; i < spb; i++)
             spba[i] = (u32)pad + (i * PAGE_SIZE);