ion: msm: Only check heap IDs if the heap has been initialized

The get_ion_heap() code blindly checks heap IDs in the array
of heap pointers without checking to see if the heap pointer
is valid, which can cause a NULL pointer to be dereferenced.

Add a check before inspecting the heap ID to ensure that the
heap pointer is valid.

Change-Id: I2ecdc652460878446e3f2daa2379e04ac021d75c
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
This commit is contained in:
Isaac J. Manjarres 2019-09-06 12:56:17 -07:00
commit e4dee59fa1

View file

@ -411,7 +411,7 @@ struct ion_heap *get_ion_heap(int heap_id)
for (i = 0; i < num_heaps; i++) {
heap = heaps[i];
if (heap->id == heap_id)
if (heap && heap->id == heap_id)
return heap;
}