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

Re: [PATCH v3] gpudev: manage NULL pointer

From: Thomas Monjalon <hidden>
Date: 2021-11-22 11:51:51

22/11/2021 12:34, Elena Agostini:
From: Thomas Monjalon <redacted>
quoted
22/11/2021 19:24, eagostini@nvidia.com:
quoted
--- a/lib/gpudev/gpudev.c
+++ b/lib/gpudev/gpudev.c
@@ -569,6 +569,9 @@ rte_gpu_mem_free(int16_t dev_id, void *ptr)
 {
      struct rte_gpu *dev;

+     if (ptr == NULL)
+             return 0;
+
      dev = gpu_get_by_id(dev_id);
      if (dev == NULL) {
              GPU_LOG(ERR, "free mem for invalid device ID %d", dev_id);>
quoted
I think we should keep this check first.
Why should gpudev waste more latency in looking for the device if the ptr is NULL?
Freeing with NULL pointer is not in the datapath I think,
probably just a failure cleanup case.
Having the dev_id check first allows to catch more bugs.
Returning 0 without checking the id looks weird to me.


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help