From: Matthew Brost <matthew.brost@intel.com>
To: <intel-xe@lists.freedesktop.org>
Cc: "Matthew Brost" <matthew.brost@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: [PATCH] drm/xe: Do not dereference NULL job->fence in trace points
Date: Tue, 4 Jun 2024 22:50:41 -0700 [thread overview]
Message-ID: <20240605055041.2082074-1-matthew.brost@intel.com> (raw)
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>
---
drivers/gpu/drm/xe/xe_sched_job.h | 2 +-
drivers/gpu/drm/xe/xe_trace.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_sched_job.h b/drivers/gpu/drm/xe/xe_sched_job.h
index 002c3b5c0a5c..f362e28455db 100644
--- a/drivers/gpu/drm/xe/xe_sched_job.h
+++ b/drivers/gpu/drm/xe/xe_sched_job.h
@@ -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)
diff --git a/drivers/gpu/drm/xe/xe_trace.h b/drivers/gpu/drm/xe/xe_trace.h
index 450f407c66e8..e4cba64474e6 100644
--- a/drivers/gpu/drm/xe/xe_trace.h
+++ b/drivers/gpu/drm/xe/xe_trace.h
@@ -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;
),
--
2.34.1
next reply other threads:[~2024-06-05 5:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 5:50 Matthew Brost [this message]
2024-06-05 7:26 ` ✓ CI.Patch_applied: success for drm/xe: Do not dereference NULL job->fence in trace points Patchwork
2024-06-05 7:26 ` ✗ CI.checkpatch: warning " Patchwork
2024-06-05 7:27 ` ✓ CI.KUnit: success " Patchwork
2024-06-05 7:39 ` ✓ CI.Build: " Patchwork
2024-06-05 7:39 ` ✗ CI.Hooks: failure " Patchwork
2024-06-05 7:40 ` ✓ CI.checksparse: success " Patchwork
2024-06-05 8:12 ` ✓ CI.BAT: " Patchwork
2024-06-05 18:38 ` ✗ CI.FULL: failure " Patchwork
2024-06-05 23:13 ` [PATCH] " Lucas De Marchi
2024-06-06 2:55 ` Matthew Brost
2024-06-06 5:21 ` Lucas De Marchi
2024-06-06 16:23 ` Matthew Brost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240605055041.2082074-1-matthew.brost@intel.com \
--to=matthew.brost@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=thomas.hellstrom@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox