diff options
author | Frank Gevaerts <frank@gevaerts.be> | 2014-01-05 20:56:16 +0100 |
---|---|---|
committer | Frank Gevaerts <frank@gevaerts.be> | 2014-01-05 20:56:55 +0100 |
commit | 2a63502c09bc72cd1d0f75b9c1bb13b53c7a35c4 (patch) | |
tree | 3653263b370d11f058faa4d5fa95d07cc2e6cc69 | |
parent | 463d343102c491d59a0bdb31debe5b11c92e7877 (diff) |
Check that core_alloc_maximum() returned something useful, and panic if not
Change-Id: I7ae40db0f81d1d51742501936b13b387f94a25e5
-rw-r--r-- | firmware/usbstack/usb_storage.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index a3b867319d..a439ad4bf0 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c @@ -35,6 +35,7 @@ #include "timefuncs.h" #endif #include "core_alloc.h" +#include "panic.h" #ifdef USB_USE_RAMDISK #define RAMDISK_SIZE 2048 @@ -460,6 +461,10 @@ void usb_storage_init_connection(void) static struct buflib_callbacks dummy_ops; usb_handle = core_alloc_maximum("usb storage", &bufsize, &dummy_ops); + if (usb_handle < 0) + panicf("%s(): OOM", __func__); + if (bufsize < ALLOCATE_BUFFER_SIZE + MAX_CBW_SIZE + 31) + panicf("%s(): got only %d, not enough", __func__, bufsize); buffer = core_get_data(usb_handle); #if defined(UNCACHED_ADDR) && CONFIG_CPU != AS3525 cbw_buffer = (void *)UNCACHED_ADDR((unsigned int)(buffer+31) & 0xffffffe0); |