public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe/eustall: Fix drm_dev_put called before stream disable in close
@ 2026-04-15 22:54 Shuicheng Lin
  2026-04-15 23:03 ` ✗ CI.checkpatch: warning for " Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Shuicheng Lin @ 2026-04-15 22:54 UTC (permalink / raw)
  To: intel-xe; +Cc: Shuicheng Lin, Harish Chegondi

In xe_eu_stall_stream_close(), drm_dev_put() is called before the
stream is disabled and its resources are freed. If this drops the
last reference, the device structures could be freed while the
subsequent cleanup code still accesses them, leading to a
use-after-free.

Fix this by moving drm_dev_put() after all device accesses are
complete. This matches the ordering in xe_oa_release().

Fixes: 9a0b11d4cf3b ("drm/xe/eustall: Add support to init, enable and disable EU stall sampling")
Cc: Harish Chegondi <harish.chegondi@intel.com>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
---
 drivers/gpu/drm/xe/xe_eu_stall.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_eu_stall.c b/drivers/gpu/drm/xe/xe_eu_stall.c
index aaf3fcc12363..b88b6c49c54a 100644
--- a/drivers/gpu/drm/xe/xe_eu_stall.c
+++ b/drivers/gpu/drm/xe/xe_eu_stall.c
@@ -871,14 +871,14 @@ static int xe_eu_stall_stream_close(struct inode *inode, struct file *file)
 	struct xe_eu_stall_data_stream *stream = file->private_data;
 	struct xe_gt *gt = stream->gt;
 
-	drm_dev_put(&gt->tile->xe->drm);
-
 	mutex_lock(&gt->eu_stall->stream_lock);
 	xe_eu_stall_disable_locked(stream);
 	xe_eu_stall_data_buf_destroy(stream);
 	xe_eu_stall_stream_free(stream);
 	mutex_unlock(&gt->eu_stall->stream_lock);
 
+	drm_dev_put(&gt->tile->xe->drm);
+
 	return 0;
 }
 
-- 
2.43.0


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

end of thread, other threads:[~2026-04-16 20:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-15 22:54 [PATCH] drm/xe/eustall: Fix drm_dev_put called before stream disable in close Shuicheng Lin
2026-04-15 23:03 ` ✗ CI.checkpatch: warning for " Patchwork
2026-04-15 23:04 ` ✓ CI.KUnit: success " Patchwork
2026-04-15 23:55 ` ✓ Xe.CI.BAT: " Patchwork
2026-04-16  1:44 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-04-16 20:09   ` Matt Roper
2026-04-16 17:47 ` [PATCH] " Harish Chegondi

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