Skip to contentSkip to conversation

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

PATCH In review Rajendra Nayak 2 participants 2 messages Jul 20, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/msm/dpu: dev_pm_opp_put_clkname() only when an opp_table exists

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")
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +2 -1
index f2bbce4..843a1c1 100644
@@ -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 = {
Signature · 7 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Tested-by on v1 1/1
#1 lore raw
Quoted 27 lines · Rajendra Nayak

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")
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +2 -1
index f2bbce4..843a1c1 100644
@@ -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);
 }
 
Quoted 1 line

static const struct component_ops dpu_ops = {

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation