From: Matthew Brost <matthew.brost@intel.com>
To: Nirmoy Das <nirmoy.das@linux.intel.com>
Cc: <apoorva.singh@intel.com>, <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH] drm/xe: Add NULL check before deferencing pointer
Date: Wed, 14 Aug 2024 16:42:49 +0000 [thread overview]
Message-ID: <ZrzeiWJ5zTCqN3Ae@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <d3a3cccf-e615-4620-97d7-0bcb75ef41f0@linux.intel.com>
On Wed, Aug 14, 2024 at 01:02:45PM +0200, Nirmoy Das wrote:
>
> On 8/14/2024 12:17 PM, apoorva.singh@intel.com wrote:
> > From: Apoorva Singh <apoorva.singh@intel.com>
> >
> > - Add NULL check before deferencing of lrc->bo in
> > xe_lrc_snapshot_capture()
> >
> > Signed-off-by: Apoorva Singh <apoorva.singh@intel.com>
> > ---
> > drivers/gpu/drm/xe/xe_lrc.c | 32 ++++++++++++++++++--------------
> > 1 file changed, 18 insertions(+), 14 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
> > index 974a9cd8c379..e31d9bc64ff6 100644
> > --- a/drivers/gpu/drm/xe/xe_lrc.c
> > +++ b/drivers/gpu/drm/xe/xe_lrc.c
> > @@ -1652,20 +1652,24 @@ struct xe_lrc_snapshot *xe_lrc_snapshot_capture(struct xe_lrc *lrc)
> > if (lrc->bo && lrc->bo->vm)
> > xe_vm_get(lrc->bo->vm);
>
>
> Looking into xe_lrc_init(), it seems we are always allocating a bo for lrc
> so remove the NULL bo check instead.
>
I agree. I recently touched this area and thought the lrc->bo was
unnecessary but didn't care to remove it. Let's go ahead and do that.
Matt
>
> Regards,
>
> Nirmoy
>
> > - snapshot->context_desc = xe_lrc_ggtt_addr(lrc);
> > - snapshot->indirect_context_desc = xe_lrc_indirect_ring_ggtt_addr(lrc);
> > - snapshot->head = xe_lrc_ring_head(lrc);
> > - snapshot->tail.internal = lrc->ring.tail;
> > - snapshot->tail.memory = xe_lrc_ring_tail(lrc);
> > - snapshot->start_seqno = xe_lrc_start_seqno(lrc);
> > - snapshot->seqno = xe_lrc_seqno(lrc);
> > - snapshot->lrc_bo = xe_bo_get(lrc->bo);
> > - snapshot->lrc_offset = xe_lrc_pphwsp_offset(lrc);
> > - snapshot->lrc_size = lrc->bo->size - snapshot->lrc_offset;
> > - snapshot->lrc_snapshot = NULL;
> > - snapshot->ctx_timestamp = xe_lrc_ctx_timestamp(lrc);
> > - snapshot->ctx_job_timestamp = xe_lrc_ctx_job_timestamp(lrc);
> > - return snapshot;
> > + if (lrc->bo) {
> > + snapshot->context_desc = xe_lrc_ggtt_addr(lrc);
> > + snapshot->indirect_context_desc = xe_lrc_indirect_ring_ggtt_addr(lrc);
> > + snapshot->head = xe_lrc_ring_head(lrc);
> > + snapshot->tail.internal = lrc->ring.tail;
> > + snapshot->tail.memory = xe_lrc_ring_tail(lrc);
> > + snapshot->start_seqno = xe_lrc_start_seqno(lrc);
> > + snapshot->seqno = xe_lrc_seqno(lrc);
> > + snapshot->lrc_bo = xe_bo_get(lrc->bo);
> > + snapshot->lrc_offset = xe_lrc_pphwsp_offset(lrc);
> > + snapshot->lrc_size = lrc->bo->size - snapshot->lrc_offset;
> > + snapshot->lrc_snapshot = NULL;
> > + snapshot->ctx_timestamp = xe_lrc_ctx_timestamp(lrc);
> > + snapshot->ctx_job_timestamp = xe_lrc_ctx_job_timestamp(lrc);
> > + return snapshot;
> > + }
> > + kfree(snapshot);
> > + return NULL;
> > }
> > void xe_lrc_snapshot_capture_delayed(struct xe_lrc_snapshot *snapshot)
next prev parent reply other threads:[~2024-08-14 16:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-14 10:17 [PATCH] drm/xe: Add NULL check before deferencing pointer apoorva.singh
2024-08-14 10:55 ` ✓ CI.Patch_applied: success for " Patchwork
2024-08-14 10:55 ` ✓ CI.checkpatch: " Patchwork
2024-08-14 10:56 ` ✓ CI.KUnit: " Patchwork
2024-08-14 11:02 ` [PATCH] " Nirmoy Das
2024-08-14 16:42 ` Matthew Brost [this message]
2024-08-14 11:08 ` ✓ CI.Build: success for " Patchwork
2024-08-14 11:10 ` ✓ CI.Hooks: " Patchwork
2024-08-14 11:11 ` ✓ CI.checksparse: " Patchwork
2024-08-14 11:21 ` [PATCH] " Jani Nikula
2024-08-14 11:31 ` ✓ CI.BAT: success for " Patchwork
2024-08-14 13:35 ` ✗ CI.FULL: failure " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2024-08-19 7:15 [PATCH] " apoorva.singh
2024-08-19 8:58 ` Jani Nikula
2024-08-19 9:33 ` Singh, Apoorva
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=ZrzeiWJ5zTCqN3Ae@DUT025-TGLU.fm.intel.com \
--to=matthew.brost@intel.com \
--cc=apoorva.singh@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=nirmoy.das@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