From e4dee59fa1c6c64f6c865ad69c8b1075fd0efe11 Mon Sep 17 00:00:00 2001 From: "Isaac J. Manjarres" Date: Fri, 6 Sep 2019 12:56:17 -0700 Subject: [PATCH] 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 --- drivers/staging/android/ion/msm_ion_of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/ion/msm_ion_of.c b/drivers/staging/android/ion/msm_ion_of.c index f9a3f207847a..58e86db16889 100644 --- a/drivers/staging/android/ion/msm_ion_of.c +++ b/drivers/staging/android/ion/msm_ion_of.c @@ -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; }