[PATCH 1/2] drm/i915/selftests: check the return value of i915_gem_object_trylock()

From: Rolf Eike Beer
Date: Thu Dec 19 2024 - 05:19:09 EST


A trylock can fail, in which case operating on the object is unsafe and
unconditionally unlocking is wrong.

Signed-off-by: Rolf Eike Beer <eb@xxxxxxxxx>
---
drivers/gpu/drm/i915/gt/selftest_migrate.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gt/selftest_migrate.c b/drivers/gpu/drm/i915/gt/selftest_migrate.c
index ca460cee4f8b..b2cb501febe8 100644
--- a/drivers/gpu/drm/i915/gt/selftest_migrate.c
+++ b/drivers/gpu/drm/i915/gt/selftest_migrate.c
@@ -822,7 +822,10 @@ create_init_lmem_internal(struct intel_gt *gt, size_t sz, bool try_lmem)
return obj;
}

- i915_gem_object_trylock(obj, NULL);
+ if (!i915_gem_object_trylock(obj, NULL)) {
+ i915_gem_object_put(obj);
+ return ERR_PTR(-EBUSY);
+ }
err = i915_gem_object_pin_pages(obj);
if (err) {
i915_gem_object_unlock(obj);
--
2.47.1


--
Rolf Eike Beer

emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail info@xxxxxxxxx
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com

emlix - your embedded Linux partner