check the max size of memory

This commit is contained in:
zfx
2021-06-07 17:47:58 +08:00
parent 1867ec6e18
commit 064ca9cf1f
+4
View File
@@ -47,6 +47,10 @@ static void *osal_mem_alloc(size_t size, uint32_t *type)
{
char *base = NULL;
const uint32_t mng_size = sizeof(struct mem_block);
if (size > (SIZE_MAX - mng_size)) {
HDF_LOGE("%s invalid param %d", __func__, size);
return NULL;
}
if (size > (KMALLOC_SIZE - mng_size)) {
base = (char *)vmalloc(size + mng_size);