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 <[email protected]> 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/[email protected]?part=2
