drm/bridge: samsung-dsim: Fix potential double-free in TE GPIO handling
Subsystems (4)
PATCH 1/1 drm/bridge: samsung-dsim: Fix potential double-free in TE GPIO handling
The devm_gpiod_get_optional() function uses device-managed resources that are automatically cleaned up. Thegpiod_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.
--- drivers/gpu/drm/bridge/samsung-dsim.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/bridge/samsung-dsim.c +1 -4
@@ -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,
Signature · 1 line
2.35.1
Quoted 8 lines · Miaoqian Lin
The
devm_gpiod_get_optional()function uses device-managed resources that are automatically cleaned up. Thegpiod_put()calls in both the error path ofsamsung_dsim_register_te_irq()and insamsung_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 <[email protected]>
Quoted 18 lines
--- drivers/gpu/drm/bridge/samsung-dsim.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/gpu/drm/bridge/samsung-dsim.c +0
-1@@ -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,
drivers/gpu/drm/bridge/samsung-dsim.c static int samsung_dsim_host_attach(struct mipi_dsi_host *host, · line 1796
Quoted 10 lines
drivers/gpu/drm/bridge/samsung-dsim.c +1
-3static 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
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland