]> www.infradead.org Git - users/hch/configfs.git/commitdiff
drm/xe: Do not dereference NULL job->fence in trace points
authorMatthew Brost <matthew.brost@intel.com>
Wed, 5 Jun 2024 05:50:41 +0000 (22:50 -0700)
committerMatthew Brost <matthew.brost@intel.com>
Thu, 6 Jun 2024 16:22:20 +0000 (09:22 -0700)
job->fence is not assigned until xe_sched_job_arm(), check for
job->fence in xe_sched_job_seqno() so any usage of this function (trace
points) do not result in NULL ptr dereference. Also check job->fence
before assigning error in job trace points.

Fixes: 0ac7a2c745e8 ("drm/xe: Don't initialize fences at xe_sched_job_create()")
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240605055041.2082074-1-matthew.brost@intel.com
drivers/gpu/drm/xe/xe_sched_job.h
drivers/gpu/drm/xe/xe_trace.h

index 002c3b5c0a5cbaba00108e6c63b1b53ef169039f..f362e28455dbfe92d02c747a8c8609111ba30960 100644 (file)
@@ -70,7 +70,7 @@ to_xe_sched_job(struct drm_sched_job *drm)
 
 static inline u32 xe_sched_job_seqno(struct xe_sched_job *job)
 {
-       return job->fence->seqno;
+       return job->fence ? job->fence->seqno : 0;
 }
 
 static inline u32 xe_sched_job_lrc_seqno(struct xe_sched_job *job)
index 450f407c66e8f11a9daf0318e43ff2d78eed4046..e4cba64474e6d9592773a5c9f506fba4bd359d29 100644 (file)
@@ -270,7 +270,7 @@ DECLARE_EVENT_CLASS(xe_sched_job,
                           __entry->guc_state =
                           atomic_read(&job->q->guc->state);
                           __entry->flags = job->q->flags;
-                          __entry->error = job->fence->error;
+                          __entry->error = job->fence ? job->fence->error : 0;
                           __entry->fence = job->fence;
                           __entry->batch_addr = (u64)job->ptrs[0].batch_addr;
                           ),