* [PATCH] drm/bridge: samsung-dsim: Fix potential double-free in TE GPIO handling @ 2025-08-04 12:24 ` Miaoqian Lin 2025-08-04 12:29 ` Marek Szyprowski 0 siblings, 1 reply; 2+ messages in thread From: Miaoqian Lin @ 2025-08-04 12:24 UTC (permalink / raw) To: Inki Dae, Jagan Teki, Marek Szyprowski, Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Marek Vasut, dri-devel, linux-kernel Cc: linmq006 The devm_gpiod_get_optional() function uses device-managed resources that are automatically cleaned up. The gpiod_put() calls in both the error path of samsung_dsim_register_te_irq() and in samsung_dsim_unregister_te_irq() are redundant and may lead to double-free when the device is removed. Fixes: e7447128ca4a ("drm: bridge: Generalize Exynos-DSI driver into a Samsung DSIM bridge") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> --- drivers/gpu/drm/bridge/samsung-dsim.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index bccc88d25948..6ffaee6b7738 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -1691,7 +1691,6 @@ static int samsung_dsim_register_te_irq(struct samsung_dsim *dsi, struct device IRQF_TRIGGER_RISING | IRQF_NO_AUTOEN, "TE", dsi); if (ret) { dev_err(dsi->dev, "request interrupt failed with %d\n", ret); - gpiod_put(dsi->te_gpio); return ret; } @@ -1790,10 +1789,8 @@ static int samsung_dsim_host_attach(struct mipi_dsi_host *host, static void samsung_dsim_unregister_te_irq(struct samsung_dsim *dsi) { - if (dsi->te_gpio) { + if (dsi->te_gpio) free_irq(gpiod_to_irq(dsi->te_gpio), dsi); - gpiod_put(dsi->te_gpio); - } } static int samsung_dsim_host_detach(struct mipi_dsi_host *host, -- 2.35.1 ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/bridge: samsung-dsim: Fix potential double-free in TE GPIO handling 2025-08-04 12:24 ` [PATCH] drm/bridge: samsung-dsim: Fix potential double-free in TE GPIO handling Miaoqian Lin @ 2025-08-04 12:29 ` Marek Szyprowski 0 siblings, 0 replies; 2+ messages in thread From: Marek Szyprowski @ 2025-08-04 12:29 UTC (permalink / raw) To: Miaoqian Lin, Inki Dae, Jagan Teki, Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Marek Vasut, dri-devel, linux-kernel On 04.08.2025 14:24, Miaoqian Lin wrote: > The devm_gpiod_get_optional() function uses device-managed resources that > are automatically cleaned up. The > gpiod_put() calls in both the error path of samsung_dsim_register_te_irq() > and in samsung_dsim_unregister_te_irq() are redundant and may lead to > double-free when the device is removed. > > Fixes: e7447128ca4a ("drm: bridge: Generalize Exynos-DSI driver into a Samsung DSIM bridge") > Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com> > --- > drivers/gpu/drm/bridge/samsung-dsim.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c > index bccc88d25948..6ffaee6b7738 100644 > --- a/drivers/gpu/drm/bridge/samsung-dsim.c > +++ b/drivers/gpu/drm/bridge/samsung-dsim.c > @@ -1691,7 +1691,6 @@ static int samsung_dsim_register_te_irq(struct samsung_dsim *dsi, struct device > IRQF_TRIGGER_RISING | IRQF_NO_AUTOEN, "TE", dsi); > if (ret) { > dev_err(dsi->dev, "request interrupt failed with %d\n", ret); > - gpiod_put(dsi->te_gpio); > return ret; > } > > @@ -1790,10 +1789,8 @@ static int samsung_dsim_host_attach(struct mipi_dsi_host *host, > > static void samsung_dsim_unregister_te_irq(struct samsung_dsim *dsi) > { > - if (dsi->te_gpio) { > + if (dsi->te_gpio) > free_irq(gpiod_to_irq(dsi->te_gpio), dsi); > - gpiod_put(dsi->te_gpio); > - } > } > > static int samsung_dsim_host_detach(struct mipi_dsi_host *host, Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-04 12:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20250804122429eucas1p29db20ca392de43a1d6c113dcd4b1b47d@eucas1p2.samsung.com>
2025-08-04 12:24 ` [PATCH] drm/bridge: samsung-dsim: Fix potential double-free in TE GPIO handling Miaoqian Lin
2025-08-04 12:29 ` Marek Szyprowski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®