dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm: Detect no-op drmModeAtomicRequest and return early
@ 2015-07-21 12:50 Chris Wilson
  2015-07-28 13:42 ` Emil Velikov
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Wilson @ 2015-07-21 12:50 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Stone, Emil Velikov, Rob Clark

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>
---
 xf86drmMode.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/xf86drmMode.c b/xf86drmMode.c
index 529429e..fa21986 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -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);
-- 
2.1.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-28 17:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-21 12:50 [PATCH] drm: Detect no-op drmModeAtomicRequest and return early Chris Wilson
2015-07-28 13:42 ` Emil Velikov
2015-07-28 17:10   ` Chris Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).