dma_resv_for_each_fence_unlocked(&cursor, fence) {
if (dma_resv_iter_is_restarted(&cursor)) {
+ struct dma_fence **new_fences;
unsigned int count;
while (*num_fences)
/* Eventually re-allocate the array */
#ifdef __linux__
- *fences = krealloc_array(*fences, count,
- sizeof(void *),
- GFP_KERNEL);
+ new_fences = krealloc_array(*fences, count,
+ sizeof(void *),
+ GFP_KERNEL);
#else
nfences = kmalloc(count * sizeof(void *),
GFP_KERNEL);
(count - 1) * sizeof(void *));
if (nfences) {
kfree(*fences);
- *fences = nfences;
+ new_fences = nfences;
}
#endif
- if (count && !*fences) {
+ if (count && !new_fences) {
+ kfree(*fences);
+ *fences = NULL;
+ *num_fences = 0;
dma_resv_iter_end(&cursor);
return -ENOMEM;
}
+ *fences = new_fences;
}
(*fences)[(*num_fences)++] = dma_fence_get(fence);