]> git.baikalelectronics.ru Git - kernel.git/commit
drm/i915: Fix global state use-after-frees with a refcount
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 27 May 2020 20:02:45 +0000 (23:02 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 1 Jun 2020 14:19:31 +0000 (17:19 +0300)
commitf45e4aefd409a3caf1f87135bae0077b989e3840
tree665c5f7233606dfe27af64751d406a99c36008b0
parentaf646b38f8d2716de156fd754020fe0cf70f81d3
drm/i915: Fix global state use-after-frees with a refcount

While the current locking/serialization of the global state
suffices for protecting the obj->state access and the actual
hardware reprogramming, we do have a problem with accessing
the old/new states during nonblocking commits.

The state computation and swap will be protected by the crtc
locks, but the commit_tails can finish out of order, thus also
causing the atomic states to be cleaned up out of order. This
would mean the commit that started first but finished last has
had its new state freed as the no-longer-needed old state by the
other commit.

To fix this let's just refcount the states. obj->state amounts
to one reference, and the intel_atomic_state holds extra references
to both its new and old global obj states.

Fixes: f50afe545c20 ("drm/i915: Introduce better global state handling")
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200527200245.13184-1-ville.syrjala@linux.intel.com
Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
drivers/gpu/drm/i915/display/intel_global_state.c
drivers/gpu/drm/i915/display/intel_global_state.h