mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/xe: clear backup ERR_PTR before retrying in xe_bo_evict_pinned()
@ 2026-11-20 19:20 Elkin Cruz
  0 siblings, 0 replies; only message in thread
From: Elkin Cruz @ 2026-11-20 19:20 UTC (permalink / raw)
  To: Matthew Brost, Thomas Hellström, Rodrigo Vivi, David Airlie,
	Simona Vetter
  Cc: intel-xe, dri-devel, linux-kernel, llvm, irogers, Elkin Cruz

In xe_bo_evict_pinned(), backup is initialized to bo->backup_obj (NULL)
outside xe_validation_guard(). When xe_bo_init_locked() returns an
ERR_PTR on lock contention (-EDEADLK) or OOM (-ENOMEM),
drm_exec_retry_on_contention(&exec) or
xe_validation_retry_on_oom(&ctx, &ret) restarts the loop while backup
still holds the ERR_PTR. On the retried iteration, "if (!backup)" is
false, passing the ERR_PTR directly to xe_bo_evict_pinned_copy().

Extract ret = PTR_ERR(backup) and reset backup to NULL before
retrying.

Fixes: 844150c255c9 ("drm/xe: Convert pinned suspend eviction for exhaustive eviction")
Signed-off-by: Elkin Cruz <elkin@google.com>
---
I am trying out a new Clang static analysis linter for ERR_PTR/NULL
handling, and it flagged this code as possibly buggy. The findings were triaged
and fixed with an AI coding assistant, then checked against linux-next (not
runtime-tested on hardware).

Thanks,
Elkin

 drivers/gpu/drm/xe/xe_bo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 353ac1e9a9d6..ae6fd20304ce 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -1680,8 +1680,9 @@ int xe_bo_evict_pinned(struct xe_bo *bo)
 						   XE_BO_FLAG_SYSTEM | XE_BO_FLAG_NEEDS_CPU_ACCESS |
 						   XE_BO_FLAG_PINNED, NULL, &exec);
 			if (IS_ERR(backup)) {
-				drm_exec_retry_on_contention(&exec);
 				ret = PTR_ERR(backup);
+				backup = NULL;
+				drm_exec_retry_on_contention(&exec);
 				xe_validation_retry_on_oom(&ctx, &ret);
 				break;
 			}
-- 
2.56.1.750.gf70dc682cf-goog


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

only message in thread, other threads:[~2026-11-20 19:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 19:20 [PATCH] drm/xe: clear backup ERR_PTR before retrying in xe_bo_evict_pinned() Elkin Cruz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®