drm/msm: dsi: dev_pm_opp_put_clkname() only when an opp_table exists
diff mbox series

Message ID 1595246509-6584-1-git-send-email-rnayak@codeaurora.org
State New
Headers show
Series
  • drm/msm: dsi: dev_pm_opp_put_clkname() only when an opp_table exists
Related show

Commit Message

Rajendra Nayak July 20, 2020, 12:01 p.m. UTC
Its possible for msm_dsi_host_init() to fail early, before
dev_pm_opp_set_clkname() is called. In such cases, unconditionally
calling dev_pm_opp_put_clkname() in msm_dsi_host_destroy() results
in a crash. Put an additional check so that dev_pm_opp_put_clkname()
is called only when an opp_table exists.

Fixes: f99131fa7a23 ("drm/msm: dsi: Use OPP API to set clk/perf state")
Reported-by: Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>
Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
---
 drivers/gpu/drm/msm/dsi/dsi_host.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Sai Prakash Ranjan July 20, 2020, 2:08 p.m. UTC | #1
On 2020-07-20 17:31, Rajendra Nayak wrote:
> Its possible for msm_dsi_host_init() to fail early, before
> dev_pm_opp_set_clkname() is called. In such cases, unconditionally
> calling dev_pm_opp_put_clkname() in msm_dsi_host_destroy() results
> in a crash. Put an additional check so that dev_pm_opp_put_clkname()
> is called only when an opp_table exists.
> 
> Fixes: f99131fa7a23 ("drm/msm: dsi: Use OPP API to set clk/perf state")
> Reported-by: Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
> ---
>  drivers/gpu/drm/msm/dsi/dsi_host.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c
> b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index 0a14c4a..4f580f7 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -1936,7 +1936,8 @@ void msm_dsi_host_destroy(struct mipi_dsi_host 
> *host)
> 
>  	if (msm_host->has_opp_table)
>  		dev_pm_opp_of_remove_table(&msm_host->pdev->dev);
> -	dev_pm_opp_put_clkname(msm_host->opp_table);
> +	if (msm_host->opp_table)
> +		dev_pm_opp_put_clkname(msm_host->opp_table);
>  	pm_runtime_disable(&msm_host->pdev->dev);
>  }

Tested-by: Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>

Patch
diff mbox series

diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 0a14c4a..4f580f7 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1936,7 +1936,8 @@  void msm_dsi_host_destroy(struct mipi_dsi_host *host)
 
 	if (msm_host->has_opp_table)
 		dev_pm_opp_of_remove_table(&msm_host->pdev->dev);
-	dev_pm_opp_put_clkname(msm_host->opp_table);
+	if (msm_host->opp_table)
+		dev_pm_opp_put_clkname(msm_host->opp_table);
 	pm_runtime_disable(&msm_host->pdev->dev);
 }