Skip to content

Commit

Permalink
dma-buf: Check for empty dma_fence_array
Browse files Browse the repository at this point in the history
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Tejas Upadhyay <tejaskumarx.surendrakumar.upadhyay@intel.com>
  • Loading branch information
tejaskux authored and intel-lab-lkp committed Mar 28, 2022
1 parent 8515d05 commit 2a2ee3b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/dma-buf/dma-fence-array.c
Expand Up @@ -159,6 +159,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
struct dma_fence_array *array;
size_t size = sizeof(*array);

WARN_ON(!num_fences || !fences);

/* Allocate the callback structures behind the array. */
size += num_fences * sizeof(struct dma_fence_array_cb);
array = kzalloc(size, GFP_KERNEL);
Expand Down Expand Up @@ -231,6 +233,9 @@ struct dma_fence *dma_fence_array_first(struct dma_fence *head)
if (!array)
return head;

if (!array->num_fences)
return NULL;

return array->fences[0];
}
EXPORT_SYMBOL(dma_fence_array_first);
Expand Down

0 comments on commit 2a2ee3b

Please sign in to comment.