diff mbox series

[v3] app/test-gpudev: remove all memory leaks

Message ID 20211125230332.15709-1-eagostini@nvidia.com (mailing list archive)
State Accepted, archived
Headers show
Series [v3] app/test-gpudev: remove all memory leaks | expand

Checks

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

Commit Message

Elena Agostini Nov. 25, 2021, 11:03 p.m. UTC
From: Elena Agostini <eagostini@nvidia.com>

Remove all memory leaks in case of errors in
test-gpudev application.

Fixes: e818c4e2bf50 ("gpudev: add memory API")
Fixes: c7ebd65c1372 ("gpudev: add communication list")

Signed-off-by: Elena Agostini <eagostini@nvidia.com>
---
 app/test-gpudev/main.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Comments

Thomas Monjalon Nov. 26, 2021, 12:17 p.m. UTC | #1
26/11/2021 00:03, eagostini@nvidia.com:
> From: Elena Agostini <eagostini@nvidia.com>
> 
> Remove all memory leaks in case of errors in
> test-gpudev application.
> 
> Fixes: e818c4e2bf50 ("gpudev: add memory API")
> Fixes: c7ebd65c1372 ("gpudev: add communication list")
> 
> Signed-off-by: Elena Agostini <eagostini@nvidia.com>

Applied, thanks.
diff mbox series

Patch

diff --git a/app/test-gpudev/main.c b/app/test-gpudev/main.c
index c647e30de4..5c1aa3d52f 100644
--- a/app/test-gpudev/main.c
+++ b/app/test-gpudev/main.c
@@ -117,6 +117,10 @@  alloc_gpu_memory(uint16_t gpu_id)
 	return 0;
 
 error:
+
+	rte_gpu_mem_free(gpu_id, ptr_1);
+	rte_gpu_mem_free(gpu_id, ptr_2);
+
 	printf("\n=======> TEST: FAILED\n");
 	return -1;
 }
@@ -161,10 +165,15 @@  register_cpu_memory(uint16_t gpu_id)
 	}
 	printf("CPU memory 0x%p unregistered\n", ptr);
 
+	rte_free(ptr);
+
 	printf("\n=======> TEST: PASSED\n");
 	return 0;
 
 error:
+
+	rte_gpu_mem_unregister(gpu_id, ptr);
+	rte_free(ptr);
 	printf("\n=======> TEST: FAILED\n");
 	return -1;
 }
@@ -227,6 +236,8 @@  create_update_comm_flag(uint16_t gpu_id)
 	return 0;
 
 error:
+
+	rte_gpu_comm_destroy_flag(&devflag);
 	printf("\n=======> TEST: FAILED\n");
 	return -1;
 }
@@ -254,7 +265,7 @@  create_update_comm_list(uint16_t gpu_id)
 {
 	int ret = 0;
 	int i = 0;
-	struct rte_gpu_comm_list *comm_list;
+	struct rte_gpu_comm_list *comm_list = NULL;
 	uint32_t num_comm_items = 1024;
 	struct rte_mbuf *mbufs[10];
 
@@ -327,6 +338,10 @@  create_update_comm_list(uint16_t gpu_id)
 	return 0;
 
 error:
+
+	rte_gpu_comm_destroy_list(comm_list, num_comm_items);
+	for (i = 0; i < 10; i++)
+		rte_free(mbufs[i]);
 	printf("\n=======> TEST: FAILED\n");
 	return -1;
 }