aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson2015-07-21 07:46:45 -0500
committerChris Wilson2015-07-28 12:09:06 -0500
commit1a6efaf68e207302cd9423051b8091fa663bbabe (patch)
treea3c008c484f6b41459849bc77186463233f3b5b9 /xf86drmMode.c
parent293f8fac0a5c1cfd825005c94329aa8a5cd5ce30 (diff)
downloadexternal-libdrm-1a6efaf68e207302cd9423051b8091fa663bbabe.tar.gz
external-libdrm-1a6efaf68e207302cd9423051b8091fa663bbabe.tar.xz
external-libdrm-1a6efaf68e207302cd9423051b8091fa663bbabe.zip
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: ed44e0b9585c563905447eceed12af9c1c7ca8d4 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>
Diffstat (limited to 'xf86drmMode.c')
-rw-r--r--xf86drmMode.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 529429e8..fa219861 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -1289,7 +1289,7 @@ static int sort_req_list(const void *misc, const void *other)
1289int drmModeAtomicCommit(int fd, drmModeAtomicReqPtr req, uint32_t flags, 1289int drmModeAtomicCommit(int fd, drmModeAtomicReqPtr req, uint32_t flags,
1290 void *user_data) 1290 void *user_data)
1291{ 1291{
1292 drmModeAtomicReqPtr sorted = drmModeAtomicDuplicate(req); 1292 drmModeAtomicReqPtr sorted;
1293 struct drm_mode_atomic atomic; 1293 struct drm_mode_atomic atomic;
1294 uint32_t *objs_ptr = NULL; 1294 uint32_t *objs_ptr = NULL;
1295 uint32_t *count_props_ptr = NULL; 1295 uint32_t *count_props_ptr = NULL;
@@ -1300,7 +1300,11 @@ int drmModeAtomicCommit(int fd, drmModeAtomicReqPtr req, uint32_t flags,
1300 int obj_idx = -1; 1300 int obj_idx = -1;
1301 int ret = -1; 1301 int ret = -1;
1302 1302
1303 if (!sorted) 1303 if (req->cursor == 0)
1304 return 0;
1305
1306 sorted = drmModeAtomicDuplicate(req);
1307 if (sorted == NULL)
1304 return -ENOMEM; 1308 return -ENOMEM;
1305 1309
1306 memclear(atomic); 1310 memclear(atomic);