From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <saurabhg.gupta@intel.com>,
<alex.zuo@intel.com>, <michal.wajdeczko@intel.com>,
<matthew.d.roper@intel.com>
Subject: Re: [PATCH v2 4/5] drm/xe: Guard against NULL GT in xe_guc.c
Date: Mon, 13 Oct 2025 17:14:19 -0400 [thread overview]
Message-ID: <aO1rqyoSZS4g2C5w@intel.com> (raw)
In-Reply-To: <20250926200917.164618-11-jonathan.cavitt@intel.com>
On Fri, Sep 26, 2025 at 08:09:22PM +0000, Jonathan Cavitt wrote:
> Static analysis reveals the following issue:
> xe_device_get_gt is theoretically able to return NULL in some cases, but
> several use cases don't check the return value before performing a
> dereference, resulting in a NULL pointer dereference.
>
> Use xe_assert to assert root_gt is not NULL before dereferencing it.
>
> While we're here, replace xe_device_get_gt(xe, 0) with the equivalent
> call xe_root_mmio_gt(xe). There's no reason to use the flexible
> xe_device_get_gt function when we're only always tring to get GT0 here.
>
> v2: xe_assert root_gt is not NULL (Michal, Matt)
I really don't believe this is what they suggested.
I had understood that the suggestion was to mark the case as false
positive in the tool.
>
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Matt Roper <matthew.d.roper@intel.com>
> ---
> drivers/gpu/drm/xe/xe_guc.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
> index d5adbbb013ec..38fba439f1e8 100644
> --- a/drivers/gpu/drm/xe/xe_guc.c
> +++ b/drivers/gpu/drm/xe/xe_guc.c
> @@ -466,10 +466,13 @@ static int guc_g2g_alloc(struct xe_guc *guc)
> return 0;
>
> if (gt->info.id != 0) {
> - struct xe_gt *root_gt = xe_device_get_gt(xe, 0);
> - struct xe_guc *root_guc = &root_gt->uc.guc;
> + struct xe_gt *root_gt = xe_root_mmio_gt(xe);
> + struct xe_guc *root_guc;
> struct xe_bo *bo;
>
> + xe_assert(xe, root_gt);
> + root_guc = &root_gt->uc.guc;
> +
> bo = xe_bo_get(root_guc->g2g.bo);
> if (!bo)
> return -ENODEV;
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-10-13 21:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-26 20:09 [PATCH v2 0/5] drm/xe: Guard against NULL return for xe_device_get_gt Jonathan Cavitt
2025-09-26 20:09 ` [PATCH v2 1/5] drm/xe: Guard against NULL GT in xe_sriov_vf.c Jonathan Cavitt
2025-10-13 21:13 ` Rodrigo Vivi
2025-09-26 20:09 ` [PATCH v2 2/5] drm/xe: Guard against NULL GT in xe_pmu.c Jonathan Cavitt
2025-10-13 21:19 ` Rodrigo Vivi
2025-09-26 20:09 ` [PATCH v2 3/5] drm/xe: Don't call xe_device_get_gt twice in xe_hw_engine_lookup Jonathan Cavitt
2025-09-29 10:25 ` Upadhyay, Tejas
2025-09-26 20:09 ` [PATCH v2 4/5] drm/xe: Guard against NULL GT in xe_guc.c Jonathan Cavitt
2025-10-13 21:14 ` Rodrigo Vivi [this message]
2025-09-26 20:09 ` [PATCH v2 5/5] drm/xe/tests: Use xe_root_mmio_gt instead of xe_device_get_gt Jonathan Cavitt
2025-09-26 20:16 ` ✓ CI.KUnit: success for drm/xe: Guard against NULL return for xe_device_get_gt Patchwork
2025-09-26 20:52 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-27 3:59 ` ✗ Xe.CI.Full: failure " Patchwork
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=aO1rqyoSZS4g2C5w@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=alex.zuo@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=jonathan.cavitt@intel.com \
--cc=matthew.d.roper@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=saurabhg.gupta@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.