gpu/cuda: fix memory list cleanup
authorElena Agostini <eagostini@nvidia.com>
Tue, 21 Dec 2021 20:50:42 +0000 (20:50 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 20 Jan 2022 13:17:00 +0000 (14:17 +0100)
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")
Cc: stable@dpdk.org
Signed-off-by: Elena Agostini <eagostini@nvidia.com>
drivers/gpu/cuda/cuda.c

index 882df08..d3a7234 100644 (file)
@@ -437,9 +437,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;