Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/7] drm/xe: Guard against NULL return for xe_device_get_gt
@ 2025-10-14 16:47 Jonathan Cavitt
  2025-10-14 16:48 ` [PATCH v3 1/7] drm/xe: s/xe_device_get_gt/xe_device_lookup_gt Jonathan Cavitt
                   ` (9 more replies)
  0 siblings, 10 replies; 18+ messages in thread
From: Jonathan Cavitt @ 2025-10-14 16:47 UTC (permalink / raw)
  To: intel-xe
  Cc: saurabhg.gupta, alex.zuo, jonathan.cavitt, michal.wajdeczko,
	matthew.d.roper, rodrigo.vivi, tejas.upadhyay

Static analysis reveals the following issue:
xe_device_get_gt is theoretically able to return NULL in some cases, but
several use cases don't check the return value before performing a
dereference, resulting in a NULL pointer dereference.

Modify xe_device_get_gt to assert a non-NULL return value.  This breaks
some macros (namely, for_each_gt), so keep the old functionality in
xe_device_lookup_gt, and only use xe_device_get_gt in places where it is
necessary to assert a non-NULL return value.  Finally, add
xe_device_get_any_gt, a kunit-only macro that returns the first
available GT while asserting at least one exists, for cases where the GT
with ID 0 is masked off.

v2:
- Various commit message fixups (Michal)
- Use xe_assert in xe_guc.c (Michal, Matt)
- Add assert to vf_post_migration_recovery (Michal)
- Modify various xe_pmu functions to take an xe_gt pointer (Michal)
- Fix potential memory leak (Michal)

v3:
- Add xe_device_lookup_gt macro (Michal, Rodrigo)
- Modify xe_device_get_gt to assert gt existance (Michal, Rodrigo)
- Use xe_device_get_gt where necessary (jcavitt)
- Add xe_device_get_any_gt for kunit (jcavitt)

Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>

Jonathan Cavitt (7):
  drm/xe: s/xe_device_get_gt/xe_device_lookup_gt
  drm/xe: Don't call xe_device_lookup_gt twice in xe_hw_engine_lookup
  drm/xe/xe_device: Reintroduce xe_device_get_gt
  drm/xe: Guard against NULL GT in xe_sriov_vf.c
  drm/xe: Guard against NULL GT in xe_pmu.c
  drm/xe: Guard against NULL GT in xe_guc.c
  drm/xe/tests: Use any available GT for testing

 drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c   |  2 +-
 drivers/gpu/drm/xe/tests/xe_guc_db_mgr_test.c |  2 +-
 drivers/gpu/drm/xe/tests/xe_guc_g2g_test.c    |  2 +-
 drivers/gpu/drm/xe/tests/xe_guc_relay_test.c  |  8 ++--
 drivers/gpu/drm/xe/xe_device.h                | 41 ++++++++++++++++++-
 drivers/gpu/drm/xe/xe_eu_stall.c              |  2 +-
 drivers/gpu/drm/xe/xe_exec_queue.c            |  2 +-
 drivers/gpu/drm/xe/xe_hw_engine.c             |  5 +--
 drivers/gpu/drm/xe/xe_pmu.c                   | 13 +++---
 drivers/gpu/drm/xe/xe_query.c                 |  2 +-
 10 files changed, 59 insertions(+), 20 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2025-10-15  2:37 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-14 16:47 [PATCH v3 0/7] drm/xe: Guard against NULL return for xe_device_get_gt Jonathan Cavitt
2025-10-14 16:48 ` [PATCH v3 1/7] drm/xe: s/xe_device_get_gt/xe_device_lookup_gt Jonathan Cavitt
2025-10-14 17:17   ` Michal Wajdeczko
2025-10-14 17:21     ` Cavitt, Jonathan
2025-10-14 16:48 ` [PATCH v3 2/7] drm/xe: Don't call xe_device_lookup_gt twice in xe_hw_engine_lookup Jonathan Cavitt
2025-10-14 16:48 ` [PATCH v3 3/7] drm/xe/xe_device: Reintroduce xe_device_get_gt Jonathan Cavitt
2025-10-14 17:28   ` Michal Wajdeczko
2025-10-14 16:48 ` [PATCH v3 4/7] drm/xe: Guard against NULL GT in xe_sriov_vf.c Jonathan Cavitt
2025-10-14 17:32   ` Michal Wajdeczko
2025-10-14 17:34     ` Cavitt, Jonathan
2025-10-14 16:48 ` [PATCH v3 5/7] drm/xe: Guard against NULL GT in xe_pmu.c Jonathan Cavitt
2025-10-14 16:48 ` [PATCH v3 6/7] drm/xe: Guard against NULL GT in xe_guc.c Jonathan Cavitt
2025-10-14 16:48 ` [PATCH v3 7/7] drm/xe/tests: Use any available GT for testing Jonathan Cavitt
2025-10-14 17:51   ` Michal Wajdeczko
2025-10-14 18:06     ` Cavitt, Jonathan
2025-10-14 16:55 ` ✓ CI.KUnit: success for drm/xe: Guard against NULL return for xe_device_get_gt Patchwork
2025-10-14 17:44 ` ✓ Xe.CI.BAT: " Patchwork
2025-10-15  2:37 ` ✗ Xe.CI.Full: failure " Patchwork

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