mirror of
https://github.com/openharmony/drivers_adapter_khdf_linux.git
synced 2026-07-21 03:55:21 -04:00
check the max size of memory
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user