gpudev: manage null parameters in memory functions
The gpudev functions free, register and unregister
return gracefully if input pointer is NULL or size 0,
as API doc was indicating no-op accepted values.
CUDA driver checks are removed because redundant
with the checks added in gpudev library.
Fixes: e818c4e2bf
("gpudev: add memory API")
Signed-off-by: Elena Agostini <eagostini@nvidia.com>
This commit is contained in:
parent
0c6e27549c
commit
1674c56dc3
@ -569,8 +569,6 @@ cuda_mem_alloc(struct rte_gpu *dev, size_t size, void **ptr)
|
||||
|
||||
if (dev == NULL)
|
||||
return -ENODEV;
|
||||
if (size == 0)
|
||||
return -EINVAL;
|
||||
|
||||
/* Store current ctx */
|
||||
res = pfn_cuCtxGetCurrent(¤t_ctx);
|
||||
@ -652,9 +650,6 @@ cuda_mem_register(struct rte_gpu *dev, size_t size, void *ptr)
|
||||
if (dev == NULL)
|
||||
return -ENODEV;
|
||||
|
||||
if (size == 0 || ptr == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
/* Store current ctx */
|
||||
res = pfn_cuCtxGetCurrent(¤t_ctx);
|
||||
if (res != 0) {
|
||||
@ -764,9 +759,6 @@ cuda_mem_free(struct rte_gpu *dev, void *ptr)
|
||||
if (dev == NULL)
|
||||
return -ENODEV;
|
||||
|
||||
if (ptr == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
hk = get_hash_from_ptr((void *)ptr);
|
||||
|
||||
mem_item = mem_list_find_item(hk);
|
||||
@ -803,9 +795,6 @@ cuda_mem_unregister(struct rte_gpu *dev, void *ptr)
|
||||
if (dev == NULL)
|
||||
return -ENODEV;
|
||||
|
||||
if (ptr == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
hk = get_hash_from_ptr((void *)ptr);
|
||||
|
||||
mem_item = mem_list_find_item(hk);
|
||||
|
@ -580,6 +580,10 @@ rte_gpu_mem_free(int16_t dev_id, void *ptr)
|
||||
rte_errno = ENOTSUP;
|
||||
return -rte_errno;
|
||||
}
|
||||
|
||||
if (ptr == NULL) /* dry-run */
|
||||
return 0;
|
||||
|
||||
return GPU_DRV_RET(dev->ops.mem_free(dev, ptr));
|
||||
}
|
||||
|
||||
@ -601,8 +605,8 @@ rte_gpu_mem_register(int16_t dev_id, size_t size, void *ptr)
|
||||
return -rte_errno;
|
||||
}
|
||||
|
||||
if (size == 0 || ptr == NULL) /* dry-run */
|
||||
return -EINVAL;
|
||||
if (ptr == NULL || size == 0) /* dry-run */
|
||||
return 0;
|
||||
|
||||
return GPU_DRV_RET(dev->ops.mem_register(dev, size, ptr));
|
||||
}
|
||||
@ -623,6 +627,10 @@ rte_gpu_mem_unregister(int16_t dev_id, void *ptr)
|
||||
rte_errno = ENOTSUP;
|
||||
return -rte_errno;
|
||||
}
|
||||
|
||||
if (ptr == NULL) /* dry-run */
|
||||
return 0;
|
||||
|
||||
return GPU_DRV_RET(dev->ops.mem_unregister(dev, ptr));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user