[05/11] malloc: malloc_elem_join_adjacent_free can return null

Message ID 20221121204015.1135573-6-okaya@kernel.org (mailing list archive)
State Superseded, archived
Headers
Series codeql fixes for various subsystems |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Sinan Kaya Nov. 21, 2022, 8:40 p.m. UTC
  From: Sinan Kaya <okaya@kernel.org>

In malloc_heap_add_memory result of call to malloc_elem_join_adjacent_free
is dereferenced here and may be null.

Signed-off-by: Sinan Kaya <okaya@kernel.org>
---
 lib/eal/common/malloc_heap.c | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c
index d7c410b786..d2ccc387bf 100644
--- a/lib/eal/common/malloc_heap.c
+++ b/lib/eal/common/malloc_heap.c
@@ -97,6 +97,9 @@  malloc_heap_add_memory(struct malloc_heap *heap, struct rte_memseg_list *msl,
 	malloc_elem_insert(elem);
 
 	elem = malloc_elem_join_adjacent_free(elem);
+	if (!elem) {
+		return NULL;
+	}
 
 	malloc_elem_free_list_insert(elem);