drm: Detect no-op drmModeAtomicRequest and return early

If the number of items to process in the request is zero, we can forgo
duplicating, sorting the request and feeding it into the kernel and
instead report success immediately.  This prevents a NULL dereference of
the sorted->items for the no-op request.

Fixes: ed44e0b958
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Rob Clark <robclark@freedesktop.org>
Cc: Daniel Stone <daniels@collabora.com>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
main
Chris Wilson 2015-07-21 13:46:45 +01:00
parent 293f8fac0a
commit 1a6efaf68e
1 changed files with 6 additions and 2 deletions

View File

@ -1289,7 +1289,7 @@ static int sort_req_list(const void *misc, const void *other)
int drmModeAtomicCommit(int fd, drmModeAtomicReqPtr req, uint32_t flags,
void *user_data)
{
drmModeAtomicReqPtr sorted = drmModeAtomicDuplicate(req);
drmModeAtomicReqPtr sorted;
struct drm_mode_atomic atomic;
uint32_t *objs_ptr = NULL;
uint32_t *count_props_ptr = NULL;
@ -1300,7 +1300,11 @@ int drmModeAtomicCommit(int fd, drmModeAtomicReqPtr req, uint32_t flags,
int obj_idx = -1;
int ret = -1;
if (!sorted)
if (req->cursor == 0)
return 0;
sorted = drmModeAtomicDuplicate(req);
if (sorted == NULL)
return -ENOMEM;
memclear(atomic);