From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Jonathan Cavitt <jonathan.cavitt@intel.com>,
<intel-xe@lists.freedesktop.org>
Cc: <saurabhg.gupta@intel.com>, <alex.zuo@intel.com>
Subject: Re: [PATCH 1/5] drm/xe: Guard against NULL GT in xe_sriov_vf.c
Date: Fri, 26 Sep 2025 20:10:31 +0200 [thread overview]
Message-ID: <dd003ac0-510f-4b12-976a-006a7839a1e8@intel.com> (raw)
In-Reply-To: <20250926155948.145934-8-jonathan.cavitt@intel.com>
On 9/26/2025 5:59 PM, 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.
>
> Add guards against this in xe_sriov_vf.c:
> - Use xe_root_mmio_gt instead of xe_device_get_gt for the tile 0 case.
> - Check the return value of xe_device_get_gt when this is not possible.
>
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> ---
> drivers/gpu/drm/xe/xe_sriov_vf.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_sriov_vf.c b/drivers/gpu/drm/xe/xe_sriov_vf.c
> index cdd9f8e78b2a..28b9c40d79f0 100644
> --- a/drivers/gpu/drm/xe/xe_sriov_vf.c
> +++ b/drivers/gpu/drm/xe/xe_sriov_vf.c
> @@ -178,7 +178,7 @@ static void vf_migration_init_early(struct xe_device *xe)
> if (!IS_DGFX(xe)) {
> struct xe_uc_fw_version guc_version;
>
> - xe_gt_sriov_vf_guc_versions(xe_device_get_gt(xe, 0), NULL, &guc_version);
> + xe_gt_sriov_vf_guc_versions(xe_root_mmio_gt(xe), NULL, &guc_version);
> if (MAKE_GUC_VER_STRUCT(guc_version) < MAKE_GUC_VER(1, 23, 0))
> return vf_disable_migration(xe,
> "CCS migration requires GuC ABI >= 1.23 but only %u.%u found",
> @@ -361,6 +361,11 @@ static void vf_post_migration_recovery(struct xe_device *xe)
> while (id = vf_get_next_migrated_gt_id(xe), id >= 0) {
> struct xe_gt *gt = xe_device_get_gt(xe, id);
>
I'm not sure this can ever fail, as ID it taken from vf_get_next_migrated_gt_id()
which uses the for_each_gt loop, so all IDs are taken from existing GTs, there is no guess
maybe just assert here?
> + if (!gt) {
> + err = -ENODEV;
> + goto fail;
> + }
> +
> err = gt_vf_post_migration_fixups(gt);
> if (err)
> goto fail;
next prev parent reply other threads:[~2025-09-26 18:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-26 15:59 [PATCH 0/5] drm/xe: Guard against NULL return for xe_device_get_gt Jonathan Cavitt
2025-09-26 15:59 ` [PATCH 1/5] drm/xe: Guard against NULL GT in xe_sriov_vf.c Jonathan Cavitt
2025-09-26 18:10 ` Michal Wajdeczko [this message]
2025-09-26 15:59 ` [PATCH 2/5] drm/xe: Guard against NULL GT in xe_pmu.c Jonathan Cavitt
2025-09-26 18:26 ` Michal Wajdeczko
2025-09-29 10:40 ` Upadhyay, Tejas
2025-09-29 15:41 ` Cavitt, Jonathan
2025-09-26 15:59 ` [PATCH 3/5] drm/xe: Don't call xe_device_get_gt twice in xe_hw_engine_lookup Jonathan Cavitt
2025-09-26 18:28 ` Michal Wajdeczko
2025-09-26 15:59 ` [PATCH 4/5] drm/xe: Guard against NULL GT in xe_guc.c Jonathan Cavitt
2025-09-26 18:36 ` Michal Wajdeczko
2025-09-26 19:26 ` Matt Roper
2025-09-26 22:04 ` Michal Wajdeczko
2025-09-26 15:59 ` [PATCH 5/5] drm/xe/tests: Use xe_root_mmio_gt instead of xe_device_get_gt Jonathan Cavitt
2025-09-26 18:46 ` Michal Wajdeczko
2025-09-26 16:06 ` ✓ CI.KUnit: success for drm/xe: Guard against NULL return for xe_device_get_gt Patchwork
2025-09-26 16:42 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-26 23:52 ` ✓ Xe.CI.Full: " 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=dd003ac0-510f-4b12-976a-006a7839a1e8@intel.com \
--to=michal.wajdeczko@intel.com \
--cc=alex.zuo@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=jonathan.cavitt@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox