* we already own a new reference to the fence. For num_fence > 1
* we own the reference of the dma_fence_array creation.
*/
- if (num_fences == 1) {
+
+ if (num_fences == 0) {
+ sync_file->fence = dma_fence_get_stub();
+ kfree(fences);
+
+ } else if (num_fences == 1) {
sync_file->fence = fences[0];
kfree(fences);
+
} else {
array = dma_fence_array_create(num_fences, fences,
dma_fence_context_alloc(1),
}
}
- if (index == 0)
- fences[index++] = dma_fence_get_stub();
-
- if (num_fences > index) {
- struct dma_fence **tmp;
-
- /* Keep going even when reducing the size failed */
- tmp = krealloc_array(fences, index, sizeof(*fences),
- GFP_KERNEL);
- if (tmp)
- fences = tmp;
- }
-
if (sync_file_set_fence(sync_file, fences, index) < 0)
goto err_put_fences;