Skip to content

Commit

Permalink
drm/xe: Do not dereference NULL job->fence in trace points
Browse files Browse the repository at this point in the history
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: 0ac7a2c ("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
  • Loading branch information
Matthew Brost committed Jun 6, 2024
1 parent df433a3 commit 5d30de4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/xe/xe_sched_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/xe/xe_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
),
Expand Down

0 comments on commit 5d30de4

Please sign in to comment.