Thread (30 messages) 30 messages, 8 authors, 2021-12-09

Re: [PATCH v1] gpudev: return EINVAL if invalid input pointer for free and unregister

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2021-11-18 16:21:04

On Thu, 18 Nov 2021 19:28:02 +0000
[off-list ref] wrote:
quoted hunk ↗ jump to hunk
diff --git a/lib/gpudev/gpudev.c b/lib/gpudev/gpudev.c
index 2b174d8bd5..97575ed979 100644
--- a/lib/gpudev/gpudev.c
+++ b/lib/gpudev/gpudev.c
@@ -576,6 +576,11 @@ rte_gpu_mem_free(int16_t dev_id, void *ptr)
 		return -rte_errno;
 	}
 
+	if (ptr == NULL) {
+		rte_errno = EINVAL;
+		return -rte_errno;
+	}
+
The convention for free(), and rte_free() is that calling free
with a NULL pointer is a nop. Why not follow those?

This would keep programmers from having to view GPU as a
special case.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help