summaryrefslogtreecommitdiffstats
path: root/drivers/dma-buf
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2022-03-25 16:38:54 +0100
committerChristian König <christian.koenig@amd.com>2022-03-29 09:14:30 +0200
commitc42ee39c1e78224d3a81bdbe0600abe4581226ed (patch)
tree995de856a17d9f0b5fbd4ea5b85aa15f9e78888f /drivers/dma-buf
parent21d139d73f776aed1e86f3175a1e9fb8a10930c7 (diff)
downloadlinux-c42ee39c1e78224d3a81bdbe0600abe4581226ed.tar.bz2
dma-buf: handle empty dma_fence_arrays gracefully
A bug inside the new sync-file merge code created empty dma_fence_array instances. Warn about that and handle those without crashing. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220329070001.134180-2-christian.koenig@amd.com
Diffstat (limited to 'drivers/dma-buf')
-rw-r--r--drivers/dma-buf/dma-fence-array.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
index 52b85d292383..5c8a7084577b 100644
--- a/drivers/dma-buf/dma-fence-array.c
+++ b/drivers/dma-buf/dma-fence-array.c
@@ -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);
@@ -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);