[v1] gpu/cuda: fix memory list cleanup

Message ID 20211221205042.17289-1-eagostini@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v1] gpu/cuda: fix memory list cleanup |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance fail Performance Testing issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Elena Agostini Dec. 21, 2021, 8:50 p.m. UTC
  From: Elena Agostini <eagostini@nvidia.com>

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")

Signed-off-by: Elena Agostini <eagostini@nvidia.com>
---
 drivers/gpu/cuda/cuda.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Comments

Thomas Monjalon Jan. 20, 2022, 1:15 p.m. UTC | #1
21/12/2021 21:50, eagostini@nvidia.com:
> From: Elena Agostini <eagostini@nvidia.com>
> 
> 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")
> 
> Signed-off-by: Elena Agostini <eagostini@nvidia.com>

Applied, thanks
  

Patch

diff --git a/drivers/gpu/cuda/cuda.c b/drivers/gpu/cuda/cuda.c
index 49da215af4..afd4b92a93 100644
--- a/drivers/gpu/cuda/cuda.c
+++ b/drivers/gpu/cuda/cuda.c
@@ -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;