Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/stm: unchecked platform_get_irq() return in ltdc_unload()
--

commit 2451ff1129bd735ee3883ed5b8e4057603299d2b
Author: Guangshuo Li <[email protected]>

drm/stm: Fix potential use-after-free of pending IRQ threads

This commit frees the managed LTDC IRQs in ltdc_unload() before
pm_runtime_disable() so pending IRQ threads complete before the DRM device is
released.

> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index 5311e0b3e8dcd..35aa33f4c4593 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
> @@ -2103,8 +2103,15 @@ int ltdc_load(struct drm_device *ddev)
>  
>  void ltdc_unload(struct drm_device *ddev)
>  {
> +     struct platform_device *pdev = to_platform_device(ddev->dev);
> +     struct ltdc_device *ldev = ddev->dev_private;
> +     int i;
> +
>       drm_dbg_driver(ddev, "\n");
>  
> +     for (i = 0; i < ldev->caps.nb_irq; i++)
> +             devm_free_irq(ddev->dev, platform_get_irq(pdev, i), ddev);

[Severity: Medium]
Can platform_get_irq() fail here and pass a negative errno to devm_free_irq()?

When removing a DT overlay, of_overlay_remove() reverts the overlay properties
before of_platform_device_destroy() runs ltdc_unload(). Because OF platform
devices re-parse the interrupts property in platform_get_irq(), it fails with
-ENXIO and calls the probe-only helper dev_err_probe().

Passing that negative value as an unsigned int to devm_free_irq() triggers
WARN_ON() in devres_release() and leaves the registered IRQ active across
drm_dev_put(ddev), re-exposing the ltdc_irq_thread() use-after-free.

Saving the IRQ numbers in struct ltdc_device during ltdc_load() and freeing
those saved values in ltdc_unload() avoids re-querying the device tree during
teardown.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to