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

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

Commit Message

Rajendra Nayak July 20, 2020, 12:17 p.m. UTC
Its possible that dpu_bind() fails early enough before
dev_pm_opp_set_clkname() is called. In such cases, unconditionally
calling dev_pm_opp_put_clkname() in dpu_unbind() can result in
a crash. Put an additional check so that dev_pm_opp_put_clkname()
is called only when an opp_table exists.

Fixes: aa3950767d05 ("drm/msm/dpu: Use OPP API to set clk/perf state")
Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Sai Prakash Ranjan July 20, 2020, 12:57 p.m. UTC | #1
On 2020-07-20 17:47, Rajendra Nayak wrote:
> Its possible that dpu_bind() fails early enough before
> dev_pm_opp_set_clkname() is called. In such cases, unconditionally
> calling dev_pm_opp_put_clkname() in dpu_unbind() can result in
> a crash. Put an additional check so that dev_pm_opp_put_clkname()
> is called only when an opp_table exists.
> 
> Fixes: aa3950767d05 ("drm/msm/dpu: Use OPP API to set clk/perf state")
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> index f2bbce4..843a1c1 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> @@ -1079,7 +1079,8 @@ static void dpu_unbind(struct device *dev,
> struct device *master, void *data)
> 
>  	if (dpu_kms->has_opp_table)
>  		dev_pm_opp_of_remove_table(dev);
> -	dev_pm_opp_put_clkname(dpu_kms->opp_table);
> +	if (dpu_kms->opp_table)
> +		dev_pm_opp_put_clkname(dpu_kms->opp_table);
>  }
> 
>  static const struct component_ops dpu_ops = {

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

Patch
diff mbox series

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index f2bbce4..843a1c1 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -1079,7 +1079,8 @@  static void dpu_unbind(struct device *dev, struct device *master, void *data)
 
 	if (dpu_kms->has_opp_table)
 		dev_pm_opp_of_remove_table(dev);
-	dev_pm_opp_put_clkname(dpu_kms->opp_table);
+	if (dpu_kms->opp_table)
+		dev_pm_opp_put_clkname(dpu_kms->opp_table);
 }
 
 static const struct component_ops dpu_ops = {