Skip to contentSkip to conversation

gpu/cuda: fix memory list cleanup

PATCH Applied [email protected] 2 participants 2 messages Dec 21, 2021 – Jan 20, 2022 DRM drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpu/cuda: fix memory list cleanup

From: Elena Agostini <[email protected]>

Memory list cleanup (called by cuda_mem_free)
was not properly set the new head of the list
when deleting an entry.

Fixes 1306a73b1958 ("gpu/cuda: introduce CUDA driver")
---
 drivers/gpu/cuda/cuda.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/cuda/cuda.c +4 -2
index 49da215af4..afd4b92a93 100644
@@ -447,9 +447,11 @@ mem_list_del_item(cuda_ptr_key pk)
 		return -EINVAL;
 
 	/* if key is in head */
-	if (mem_alloc_list_cur->prev == NULL)
+	if (mem_alloc_list_cur->prev == NULL) {
 		mem_alloc_list_head = mem_alloc_list_cur->next;
-	else {
+		if (mem_alloc_list_head != NULL)
+			mem_alloc_list_head->prev = NULL;
+	} else {
 		mem_alloc_list_cur->prev->next = mem_alloc_list_cur->next;
 		if (mem_alloc_list_cur->next != NULL)
 			mem_alloc_list_cur->next->prev = mem_alloc_list_cur->prev;
Signature · 1 line
2.17.1