[PATCH v2 09/11] malloc: check result of malloc_elem_free
    okaya at kernel.org 
    okaya at kernel.org
       
    Mon Nov 21 23:32:08 CET 2022
    
    
  
From: Sinan Kaya <okaya at kernel.org>
In malloc_heap_free result of call to malloc_elem_free is dereferenced
here and may be null.
Signed-off-by: Sinan Kaya <okaya at kernel.org>
---
 lib/eal/common/malloc_heap.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c
index 88270ce4d2..6eb6fcda5e 100644
--- a/lib/eal/common/malloc_heap.c
+++ b/lib/eal/common/malloc_heap.c
@@ -892,6 +892,9 @@ malloc_heap_free(struct malloc_elem *elem)
 	/* anything after this is a bonus */
 	ret = 0;
 
+	if (elem == NULL)
+		goto free_unlock;
+
 	/* ...of which we can't avail if we are in legacy mode, or if this is an
 	 * externally allocated segment.
 	 */
-- 
2.25.1
    
    
More information about the dev
mailing list