drm/i915: Fix race in __i915_vma_remove_closed
authorKarol Herbst <kherbst@redhat.com>
Wed, 20 Apr 2022 09:57:20 +0000 (11:57 +0200)
committerJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Mon, 9 May 2022 07:36:49 +0000 (10:36 +0300)
commit3220c3b2115102bb35f8f07d90d2989a3f5eb452
tree32bb89220688bc961c600bada20cd93a4a4c345a
parentc5eb0a61238dd6faf37f58c9ce61c9980aaffd7a
drm/i915: Fix race in __i915_vma_remove_closed

i915_vma_reopen checked if the vma is closed before without taking the
lock. So multiple threads could attempt removing the vma.

Instead the lock needs to be taken before actually checking.

v2: move struct declaration

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v5.3+
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5732
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Fixes: 155ab8836caa ("drm/i915: Move object close under its own lock")
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220420095720.3331609-1-kherbst@redhat.com
(cherry picked from commit 1df1c79cbb7ac9bf148930be3418973c76ba8dde)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
drivers/gpu/drm/i915/i915_vma.c