[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20210818145159.12402-1-tim.gardner@canonical.com>
Date: Wed, 18 Aug 2021 08:51:59 -0600
From: Tim Gardner <tim.gardner@...onical.com>
To: linux-kernel@...r.kernel.org
Cc: tim.gardner@...onical.com, stable@...r.kernel.org,
kernel-janitors@...r.kernel.org,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Jani Nikula <jani.nikula@...ux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@...el.com>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-media@...r.kernel.org, linaro-mm-sig@...ts.linaro.org
Subject: [PATCH] drm/i915/gem: Avoid NULL dereference in __i915_gem_object_lock()
Coverity warns of a possible NULL dereference:
Both dma_resv_lock_interruptible() and dma_resv_lock() can return -EDEADLK. Protect
against a NULL dereference by checking for NULL before saving the object pointer. This
is consistent with previous checks for ww==NULL.
Addresses-Coverity: ("Dereference after null check")
Cc: stable@...r.kernel.org
Fixes: 80f0b679d6f0683f23cf98a511af3e44dd509472 ("drm/i915: Add an implementation for i915_gem_ww_ctx locking, v2.")
Cc: kernel-janitors@...r.kernel.org
Cc: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>
Cc: Jani Nikula <jani.nikula@...ux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@...el.com>
Cc: David Airlie <airlied@...ux.ie>
Cc: Daniel Vetter <daniel@...ll.ch>
Cc: intel-gfx@...ts.freedesktop.org
Cc: dri-devel@...ts.freedesktop.org
Cc: linux-kernel@...r.kernel.org
Cc: linux-media@...r.kernel.org
Cc: linaro-mm-sig@...ts.linaro.org
Signed-off-by: Tim Gardner <tim.gardner@...onical.com>
---
drivers/gpu/drm/i915/gem/i915_gem_object.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h
index 48112b9d76df..3391ca4f662a 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
@@ -187,7 +187,7 @@ static inline int __i915_gem_object_lock(struct drm_i915_gem_object *obj,
if (ret == -EALREADY)
ret = 0;
- if (ret == -EDEADLK) {
+ if (ret == -EDEADLK && ww) {
i915_gem_object_get(obj);
ww->contended = obj;
}
--
2.33.0
Powered by blists - more mailing lists