Check that core_alloc_maximum() returned something useful, and panic if not

Change-Id: I7ae40db0f81d1d51742501936b13b387f94a25e5
This commit is contained in:
Frank Gevaerts 2014-01-05 20:56:16 +01:00
parent 463d343102
commit 2a63502c09

View file

@ -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);