@@ -1035,6 +1035,7 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
uint32_t *idx,
ktime_t *deadline)
{
+ struct syncobj_wait_entry stack_entries[4];
struct syncobj_wait_entry *entries;
uint32_t signaled_count, i;
struct dma_fence *fence;
@@ -1049,9 +1050,14 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
!access_ok(user_points, count * sizeof(*user_points)))
return -EFAULT;
- entries = kcalloc(count, sizeof(*entries), GFP_KERNEL);
- if (!entries)
- return -ENOMEM;
+ if (count > ARRAY_SIZE(stack_entries)) {
+ entries = kcalloc(count, sizeof(*entries), GFP_KERNEL);
+ if (!entries)
+ return -ENOMEM;
+ } else {
+ memset(stack_entries, 0, sizeof(stack_entries));
+ entries = stack_entries;
+ }
/* Walk the list of sync objects and initialize entries. We do
* this up-front so that we can properly return -EINVAL if there is
@@ -1174,7 +1180,9 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
&entries[i].fence_cb);
dma_fence_put(entries[i].fence);
}
- kfree(entries);
+
+ if (entries != stack_entries)
+ kfree(entries);
return timeout;
}