From 2a63502c09bc72cd1d0f75b9c1bb13b53c7a35c4 Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Sun, 5 Jan 2014 20:56:16 +0100 Subject: Check that core_alloc_maximum() returned something useful, and panic if not Change-Id: I7ae40db0f81d1d51742501936b13b387f94a25e5 --- firmware/usbstack/usb_storage.c | 5 +++++ 1 file changed, 5 insertions(+) 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); -- cgit v1.2.3