drm/vc4: fix ref count leak in vc4_dsi_encoder_enable
Subsystems (3)
PATCH 1/1 drm/vc4: fix ref count leak in vc4_dsi_encoder_enable
in vc4_dsi_encoder_enable, the call to pm_runtime_get_sync increments the counter even in case of failure, leading to incorrect ref count. In case of failure, decrement the ref count before returning.
--- drivers/gpu/drm/vc4/vc4_dsi.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_dsi.c +6 -4
@@ -838,7 +838,7 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) ret =pm_runtime_get_sync (dev);if (ret) {DRM_ERROR ("Failed to runtime PM enable on DSI%d\n" , dsi->port); -return ; + goto out; }if (debug_dump_regs) {
@@ -916,13 +916,13 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) ret =clk_prepare_enable (dsi->escape_clock);if (ret) {DRM_ERROR ("Failed to turn on DSI escape clock: %d\n" , ret); -return ; + goto out; } ret =clk_prepare_enable (dsi->pll_phy_clock);if (ret) {DRM_ERROR ("Failed to turn on DSI PLL: %d\n" , ret); -return ; + goto out; } hs_clock =clk_get_rate (dsi->pll_phy_clock);
@@ -944,7 +944,7 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) ret =clk_prepare_enable (dsi->pixel_clock);if (ret) {DRM_ERROR ("Failed to turn on DSI pixel clock: %d\n" , ret); -return ; + goto out; }/* How many ns one DSI unit interval is. Note that the clock
@@ -1088,6 +1088,8 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)dev_info (&dsi->pdev->dev,"DSI regs after:\n" );drm_print_regset32 (&p, &dsi->regset); } +out: +pm_runtime_put (dev); } static ssize_t vc4_dsi_host_transfer(struct mipi_dsi_host *host,
Signature · 1 line
2.17.1
Quoted 4 lines · Navid Emamdoost
in
vc4_dsi_encoder_enable, the call topm_runtime_get_syncincrements the counter even in case of failure, leading to incorrect ref count. In case of failure, decrement the ref count before returning.
...
drivers/gpu/drm/vc4/vc4_dsi.c static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) · line 1092
Quoted 2 lines
drivers/gpu/drm/vc4/vc4_dsi.c +2
-0+out: +pm_runtime_put (dev);
Better to use pm_runtime_put_noidle() for error case.
And here is a change of semantics, i.e. before your patch there was no put at all. How did you test this?
Signature · 6 lines
With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Navid Emamdoost
in
vc4_dsi_encoder_enable, the call topm_runtime_get_syncincrements the counter even in case of failure, leading to incorrect ref count. In case of failure, decrement the ref count before returning.
Quoted 8 lines
...
drivers/gpu/drm/vc4/vc4_dsi.c static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) · line 1092
Quoted 2 lines
drivers/gpu/drm/vc4/vc4_dsi.c +2
-0+out: +pm_runtime_put (dev);Better to use
pm_runtime_put_noidle()for error case.
And here is a change of semantics, i.e. before your patch there was no put at all. How did you test this?
I had no way to test this but looked to me like a miscalculation of ref count when there is a get and an error happens then the ref count should be restored. Does that look incorrect?
Quoted 4 lines
--
With Best Regards,
Andy Shevchenko
Signature · 1 line
Navid.