From: sashiko-bot@kernel.org
To: "Guangshuo Li" <liguangshuo@mail.sdu.edu.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/stm: Fix potential use-after-free of pending IRQ threads
Date: Thu, 03 Dec 2026 12:25:49 +0000 [thread overview]
Message-ID: <sashiko-outbox-247719@kernel.org> (raw)
In-Reply-To: <20261203115854.2319339-1-liguangshuo@mail.sdu.edu.cn>
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 <liguangshuo@mail.sdu.edu.cn>
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/20261203115854.2319339-1-liguangshuo@mail.sdu.edu.cn?part=1
prev parent reply other threads:[~2026-12-03 12:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 11:58 [PATCH] drm/stm: Fix potential use-after-free of pending IRQ threads Guangshuo Li
2026-12-03 12:25 ` sashiko-bot [this message]
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-247719@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=liguangshuo@mail.sdu.edu.cn \
--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