LKML Archive on
help / color / mirror / Atom feed
* [PATCH] drm/i915/gem: Avoid NULL dereference in __i915_gem_object_lock()
@ 2021-08-18 14:51 Tim Gardner
  0 siblings, 0 replies; only message in thread
From: Tim Gardner @ 2021-08-18 14:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: tim.gardner, stable, kernel-janitors, Maarten Lankhorst,
	Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie,
	Daniel Vetter, intel-gfx, dri-devel, linux-media, linaro-mm-sig

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")

Fixes: 80f0b679d6f0683f23cf98a511af3e44dd509472 ("drm/i915: Add an implementation for i915_gem_ww_ctx locking, v2.")
Cc: Maarten Lankhorst <>
Cc: Jani Nikula <>
Cc: Joonas Lahtinen <>
Cc: Rodrigo Vivi <>
Cc: David Airlie <>
Cc: Daniel Vetter <>
Signed-off-by: Tim Gardner <>
 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) {
 		ww->contended = obj;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-18 14:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18 14:51 [PATCH] drm/i915/gem: Avoid NULL dereference in __i915_gem_object_lock() Tim Gardner

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).