]> git.baikalelectronics.ru Git - kernel.git/commit
drm/atomic: Fix memleak on ERESTARTSYS during non-blocking commits
authorLeo (Sunpeng) Li <sunpeng.li@amd.com>
Wed, 17 Jan 2018 11:51:08 +0000 (12:51 +0100)
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Tue, 30 Jan 2018 10:27:26 +0000 (11:27 +0100)
commitae8aee01fcbb343ef17d06a0d6fced4e2bd0d216
treed5565422ba396f70805a189a082ca5ee29cb8a53
parent9bc4658c0828e23fdffd7d41ce88c6307b241988
drm/atomic: Fix memleak on ERESTARTSYS during non-blocking commits

During a non-blocking commit, it is possible to return before the
commit_tail work is queued (-ERESTARTSYS, for example).

Since a reference on the crtc commit object is obtained for the pending
vblank event when preparing the commit, the above situation will leave
us with an extra reference.

Therefore, if the commit_tail worker has not consumed the event at the
end of a commit, release it's reference.

Changes since v1:
- Also check for state->event->base.completion being set, to
  handle the case where stall_checks() fails in setup_crtc_commit().
Changes since v2:
- Add a flag to drm_crtc_commit, to prevent dereferencing a freed event.
  i915 may unreference the state in a worker.

Fixes: cbeb974fc888 ("drm: reference count event->completion")
Cc: <stable@vger.kernel.org> # v4.11+
Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com> #v1
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180117115108.29608-1-maarten.lankhorst@linux.intel.com
Reviewed-by: Sean Paul <seanpaul@chromium.org>
drivers/gpu/drm/drm_atomic_helper.c
include/drm/drm_atomic.h