Skip to contentSkip to conversation

drm/exynos: fix ref count leak in mic_pre_enable

PATCH In review Navid Emamdoost 2 participants 5 messages Jun 14, 2020 – Jun 16, 2020

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

PATCH 1/1 drm/exynos: fix ref count leak in mic_pre_enable

in mic_pre_enable, pm_runtime_get_sync is called which 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/exynos/exynos_drm_mic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_mic.c +1 -1
index a86abc173605..69ff74c2ceb5 100644
@@ -270,7 +270,7 @@ static void mic_pre_enable(struct drm_bridge *bridge)
 
 	ret = pm_runtime_get_sync(mic->dev);
 	if (ret < 0)
-		goto unlock;
+		goto turn_off;
 
 	mic_set_path(mic, 1);
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw

Hi,

20. 6. 14. 오후 3:23에 Navid Emamdoost 이(가) 쓴 글:

Quoted 14 lines

in mic_pre_enable, pm_runtime_get_sync is called which 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/exynos/exynos_drm_mic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_mic.c +0 -0
index a86abc173605..69ff74c2ceb5 100644

drivers/gpu/drm/exynos/exynos_drm_mic.c static void mic_pre_enable(struct drm_bridge *bridge) · line 273

Quoted 5 lines
drivers/gpu/drm/exynos/exynos_drm_mic.c +1 -1
@@ -270,7 +270,7 @@ static void mic_pre_enable(struct drm_bridge *bridge)
 
 	ret = pm_runtime_get_sync(mic->dev);
 	if (ret < 0)
-		goto unlock;
+		goto turn_off;

How about just calling pm_runtime_put_noidle()?

if (ret < 0) {
	pm_runtime_put_noidle(mic->dev);
	goto unlock;
}

Thanks,
Inki Dae

Quoted 4 lines
drivers/gpu/drm/exynos/exynos_drm_mic.c +0 -0
 	mic_set_path(mic, 1);
 
 
#2 lore raw

PATCH v2 1/1 drm/exynos: fix ref count leak in mic_pre_enable

in mic_pre_enable, pm_runtime_get_sync is called which increments the counter even in case of failure, leading to incorrect ref count. In case of failure, decrement the ref count before returning.

---
Changes in v2:
- reuse the unlock label and call pm_runtime_put_noidle
---

---
 drivers/gpu/drm/exynos/exynos_drm_mic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_mic.c +3 -1
index a86abc173605..3821ea76a703 100644
@@ -269,8 +269,10 @@ static void mic_pre_enable(struct drm_bridge *bridge)
 		goto unlock;
 
 	ret = pm_runtime_get_sync(mic->dev);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_noidle(mic->dev);
 		goto unlock;
+	}
 
 	mic_set_path(mic, 1);
 
Signature · 1 line
2.17.1
maintainer
#3 lore raw

20. 6. 15. 오후 2:49에 Navid Emamdoost 이(가) 쓴 글:

Quoted 8 lines

in mic_pre_enable, pm_runtime_get_sync is called which increments the counter even in case of failure, leading to incorrect ref count. In case of failure, decrement the ref count before returning.

---
Changes in v2:
- reuse the unlock label and call pm_runtime_put_noidle

Picked it up.

Thanks,
Inki Dae

Quoted 12 lines

---

---
 drivers/gpu/drm/exynos/exynos_drm_mic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_mic.c +0 -0
index a86abc173605..3821ea76a703 100644
@@ -269,8 +269,10 @@ static void mic_pre_enable(struct drm_bridge *bridge)
 		goto unlock;

drivers/gpu/drm/exynos/exynos_drm_mic.c static void mic_pre_enable(struct drm_bridge *bridge) · line 278

Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_mic.c +3 -1
 
 	ret = pm_runtime_get_sync(mic->dev);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_noidle(mic->dev);
 		goto unlock;
+	}
 
 	mic_set_path(mic, 1);
 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
In reply to Inki Dae
Quoted 26 lines · Inki Dae

Hi,

20. 6. 14. 오후 3:23에 Navid Emamdoost 이(가) 쓴 글:

Quoted 14 lines

in mic_pre_enable, pm_runtime_get_sync is called which 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/exynos/exynos_drm_mic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_mic.c +0 -0
index a86abc173605..69ff74c2ceb5 100644

drivers/gpu/drm/exynos/exynos_drm_mic.c static void mic_pre_enable(struct drm_bridge *bridge) · line 273

Quoted 5 lines
drivers/gpu/drm/exynos/exynos_drm_mic.c +1 -1
@@ -270,7 +270,7 @@ static void mic_pre_enable(struct drm_bridge *bridge)
 
      ret = pm_runtime_get_sync(mic->dev);
      if (ret < 0)
-             goto unlock;
+             goto turn_off;

How about just calling pm_runtime_put_noidle()?

Quoted 5 lines
if (ret < 0) {
        pm_runtime_put_noidle(mic->dev);
        goto unlock;
}

v2 was sent.

Quoted 7 lines

Thanks,
Inki Dae

Quoted 4 lines
drivers/gpu/drm/exynos/exynos_drm_mic.c +0 -0
      mic_set_path(mic, 1);
 
 
Signature · 1 line
Navid.