alloc: fix two potential NULL dereferences

bzero() doesn't check its pointer argument for NULL, the caller has
to avoid such calls.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
Guennadi Liakhovetski 2019-01-17 10:13:55 +01:00 committed by Liam Girdwood
parent 84d7eabde9
commit 5a9b8e7ee9
1 changed files with 6 additions and 2 deletions

View File

@ -597,9 +597,12 @@ void *_malloc(int zone, uint32_t caps, size_t bytes)
trace_mem_error("rmalloc() error: invalid zone"); trace_mem_error("rmalloc() error: invalid zone");
break; break;
} }
#if DEBUG_BLOCK_FREE #if DEBUG_BLOCK_FREE
bzero(ptr, bytes); if (ptr)
bzero(ptr, bytes);
#endif #endif
spin_unlock_irq(&memmap.lock, flags); spin_unlock_irq(&memmap.lock, flags);
memmap.heap_trace_updated = 1; memmap.heap_trace_updated = 1;
return ptr; return ptr;
@ -691,7 +694,8 @@ out:
ptr = cache_to_uncache(ptr); ptr = cache_to_uncache(ptr);
#if DEBUG_BLOCK_FREE #if DEBUG_BLOCK_FREE
bzero(ptr, bytes); if (ptr)
bzero(ptr, bytes);
#endif #endif
spin_unlock_irq(&memmap.lock, flags); spin_unlock_irq(&memmap.lock, flags);