From: sashiko-bot@kernel.org
To: "Baoli Zhang" <baoli.zhang@linux.intel.com>,
intel-xe@lists.freedesktop.org, intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/3] drm/i915/display: Let the drivers free the KMS objects
Date: Mon, 16 Nov 2026 01:53:07 +0000 [thread overview]
Message-ID: <sashiko-outbox-216018@kernel.org> (raw)
In-Reply-To: <20261116011504.3910139-3-baoli.zhang@linux.intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/i915/display: double intel_encoder_remove_all() on Xe
probe error
- [Medium] drm/i915/display: UAF of struct intel_display in
intel_crtc_destroy()
--
commit 4777f76b60cbdafe718dcc54b80e3edb4d081b1c
Author: Baoli Zhang <baoli.zhang@linux.intel.com>
drm/i915/display: Let the drivers free the KMS objects
This commit moves drm_mode_config_cleanup() out of
intel_mode_config_cleanup() into a new
intel_display_driver_mode_config_cleanup() helper and calls it from the
i915 and xe driver teardown paths after
intel_display_driver_remove_noirq().
> diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c b/drivers/gpu/drm/i915/display/intel_display_driver.c
> index d513cfc881069..62a4d95d78b53 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_driver.c
> +++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
> @@ -160,6 +160,18 @@ static void intel_mode_config_cleanup(struct intel_display *display)
> {
> intel_atomic_global_obj_cleanup(display);
> intel_encoder_remove_all(display);
> +}
> +
> +/*
> + * Free the KMS objects, including the encoders torn down by
> + * intel_display_driver_remove_noirq(). Userspace can keep referring to them
> + * until the last reference to the DRM device is gone.
> + */
> +void intel_display_driver_mode_config_cleanup(struct intel_display *display)
> +{
> + if (!HAS_DISPLAY(display))
> + return;
> +
> drm_mode_config_cleanup(display->drm);
> }
[Severity: Medium]
Can this cause intel_encoder_remove_all() to run twice on the same
encoders if intel_display_driver_probe_nogem() fails during
xe_display_init_early()?
When intel_display_driver_probe_nogem() fails after intel_setup_outputs()
(for example, if intel_dp_tunnel_mgr_init() fails), its err_mode_config
path calls intel_mode_config_cleanup(), which now runs
intel_encoder_remove_all() without destroying the encoders via
drm_mode_config_cleanup(). xe_display_init_early() then jumps to
err_noirq and calls intel_display_driver_remove_noirq() ->
intel_mode_config_cleanup() a second time while those encoders are still
on mode_config.encoder_list.
Running encoder->remove() twice dereferences a NULL dig_port->tc pointer
in intel_tc_port_cleanup() (which frees and clears dig_port->tc on the
first call) and double frees intel_dp->aux.name in intel_dp_aux_fini().
> diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
> index aeb7b24c81c8b..d29b37ab2833e 100644
> --- a/drivers/gpu/drm/i915/i915_driver.c
> +++ b/drivers/gpu/drm/i915/i915_driver.c
> @@ -906,6 +906,7 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> intel_display_driver_remove(display);
> intel_irq_uninstall(i915);
> intel_display_driver_remove_noirq(display);
> + intel_display_driver_mode_config_cleanup(display);
> goto out_cleanup_modeset;
> out_cleanup_irq:
> intel_irq_uninstall(i915);
[Severity: Medium]
Does the out_cleanup_irq error path in i915_driver_probe() leave CRTCs
referencing a freed struct intel_display when
intel_display_driver_probe_nogem() fails?
If intel_display_driver_probe_nogem() fails after intel_crtc_init() has
linked a CRTC onto display->pipe_list, its err_mode_config path calls
intel_mode_config_cleanup(), which no longer calls
drm_mode_config_cleanup(). i915_driver_probe() then jumps to
out_cleanup_irq, bypassing intel_display_driver_mode_config_cleanup(),
and frees display in i915_driver_late_release() ->
intel_display_device_remove(). When drmm later runs
drm_mode_config_cleanup() -> intel_crtc_destroy(),
list_del(&crtc->pipe_head) writes to display->pipe_list inside the
already-freed struct intel_display.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116011504.3910139-1-baoli.zhang@linux.intel.com?part=2
next prev parent reply other threads:[~2026-11-16 1:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 1:15 [PATCH 0/3] drm/xe/display: Free the KMS objects on DRM device release, not on unbind Baoli Zhang
2026-11-16 1:15 ` [PATCH 1/3] drm/i915/display: Tear down encoder hardware state in a separate hook Baoli Zhang
2026-11-16 1:38 ` sashiko-bot
2026-11-16 1:15 ` [PATCH 2/3] drm/i915/display: Let the drivers free the KMS objects Baoli Zhang
2026-11-16 1:53 ` sashiko-bot [this message]
2026-11-16 8:39 ` Jani Nikula
2026-11-16 1:15 ` [PATCH 3/3] drm/xe/display: Free the KMS objects on DRM device release Baoli Zhang
2026-11-16 1:54 ` sashiko-bot
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=sashiko-outbox-216018@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=baoli.zhang@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
/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