From: sashiko-bot@kernel.org
To: "Li Youhong" <dayou5941@163.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/bridge: samsung-dsim: fix TE GPIO lifetime for host attach
Date: Fri, 04 Sep 2026 02:00:42 +0000 [thread overview]
Message-ID: <20260904020043.406BD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260904014958.1572918-1-dayou5941@163.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] dsi->te_gpio is not cleared to NULL after being freed via gpiod_put() or after an ERR_PTR assignment. This leaves a dangling pointer that can lead to Use-After-Free and Double-Free bugs on subsequent attach/detach cycles or IRQ enable/disable operations.
--
commit ae0d9af500f3fda4ddfaac130c60cd01aa1ce58f
Author: Li Youhong <liyouhong@kylinos.cn>
Subject: drm/bridge: samsung-dsim: fix TE GPIO lifetime for host attach
This commit switches the TE GPIO acquisition back from
devm_gpiod_get_optional() to gpiod_get_optional() to fix a lifetime issue on
host detach/reattach. It keeps explicit gpiod_put() calls on the error path
and in samsung_dsim_unregister_te_irq().
> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
> index e2fc69fc51b60..8f3fd50e52f80 100644
> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
> @@ -1862,7 +1862,8 @@ static int samsung_dsim_register_te_irq(struct samsung_dsim *dsi, struct device
> int te_gpio_irq;
> int ret;
>
> - dsi->te_gpio = devm_gpiod_get_optional(dev, "te", GPIOD_IN);
> + /* Released on host detach; do not use the managed get. */
> + dsi->te_gpio = gpiod_get_optional(dev, "te", GPIOD_IN);
> if (!dsi->te_gpio)
> return 0;
> else if (IS_ERR(dsi->te_gpio))
[Severity: High]
This is a pre-existing issue, but is it possible we are leaving a dangling
pointer in dsi->te_gpio here?
If gpiod_get_optional() fails, dsi->te_gpio is assigned an error pointer and
the function returns early, leaving the error pointer exposed in the dsi
struct. If a video-mode panel is later attached and samsung_dsim_enable_irq()
is called, could this lead to an invalid memory access when it operates on the
error pointer?
There appear to be similar pre-existing issues where dsi->te_gpio isn't
cleared to NULL after being freed. For example, further down in the error
handling of samsung_dsim_register_te_irq():
if (ret) {
dev_err(dsi->dev, "request interrupt failed with %d\n", ret);
gpiod_put(dsi->te_gpio);
return ret;
}
And in samsung_dsim_unregister_te_irq():
if (dsi->te_gpio) {
free_irq(gpiod_to_irq(dsi->te_gpio), dsi);
gpiod_put(dsi->te_gpio);
}
Since this patch addresses detach/reattach cycles where the device isn't
destroyed, if we switch from a command-mode panel to a video-mode panel,
could these dangling pointers lead to a use-after-free or double-free on a
subsequent cycle?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260904014958.1572918-1-dayou5941@163.com?part=1
next prev parent reply other threads:[~2026-09-04 2:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 1:49 [PATCH v2] drm/bridge: samsung-dsim: fix TE GPIO lifetime for host attach Li Youhong
2026-09-04 2:00 ` sashiko-bot [this message]
2026-09-04 14:47 ` Luca Ceresoli
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=20260904020043.406BD1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dayou5941@163.com \
--cc=dri-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.