Skip to content

Commit c42ee39

Browse files
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
1 parent 21d139d commit c42ee39

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/dma-buf/dma-fence-array.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
159159
struct dma_fence_array *array;
160160
size_t size = sizeof(*array);
161161

162+
WARN_ON(!num_fences || !fences);
163+
162164
/* Allocate the callback structures behind the array. */
163165
size += num_fences * sizeof(struct dma_fence_array_cb);
164166
array = kzalloc(size, GFP_KERNEL);
@@ -231,6 +233,9 @@ struct dma_fence *dma_fence_array_first(struct dma_fence *head)
231233
if (!array)
232234
return head;
233235

236+
if (!array->num_fences)
237+
return NULL;
238+
234239
return array->fences[0];
235240
}
236241
EXPORT_SYMBOL(dma_fence_array_first);

0 commit comments

Comments
 (0)