2020-06-14 06:25:51

by Navid Emamdoost

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Navid Emamdoost <[email protected]>
---
drivers/gpu/drm/exynos/exynos_drm_mic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_mic.c b/drivers/gpu/drm/exynos/exynos_drm_mic.c
index a86abc173605..69ff74c2ceb5 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_mic.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_mic.c
@@ -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);

--
2.17.1


Subject: Re: [PATCH] drm/exynos: fix ref count leak in mic_pre_enable

Hi,

20. 6. 14. 오후 3:23에 Navid Emamdoost 이(가) 쓴 글:
> 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.
>
> Signed-off-by: Navid Emamdoost <[email protected]>
> ---
> drivers/gpu/drm/exynos/exynos_drm_mic.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_mic.c b/drivers/gpu/drm/exynos/exynos_drm_mic.c
> index a86abc173605..69ff74c2ceb5 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_mic.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_mic.c
> @@ -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

>
> mic_set_path(mic, 1);
>
>

2020-06-15 05:51:55

by Navid Emamdoost

[permalink] [raw]
Subject: [PATCH v2] 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.

Signed-off-by: Navid Emamdoost <[email protected]>
---
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(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_mic.c b/drivers/gpu/drm/exynos/exynos_drm_mic.c
index a86abc173605..3821ea76a703 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_mic.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_mic.c
@@ -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);

--
2.17.1

2020-06-15 05:53:04

by Navid Emamdoost

[permalink] [raw]
Subject: Re: [PATCH] drm/exynos: fix ref count leak in mic_pre_enable

On Sun, Jun 14, 2020 at 7:47 PM Inki Dae <[email protected]> wrote:
>
> Hi,
>
> 20. 6. 14. 오후 3:23에 Navid Emamdoost 이(가) 쓴 글:
> > 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.
> >
> > Signed-off-by: Navid Emamdoost <[email protected]>
> > ---
> > drivers/gpu/drm/exynos/exynos_drm_mic.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/exynos/exynos_drm_mic.c b/drivers/gpu/drm/exynos/exynos_drm_mic.c
> > index a86abc173605..69ff74c2ceb5 100644
> > --- a/drivers/gpu/drm/exynos/exynos_drm_mic.c
> > +++ b/drivers/gpu/drm/exynos/exynos_drm_mic.c
> > @@ -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;
> }
>
v2 was sent.

> Thanks,
> Inki Dae
>
> >
> > mic_set_path(mic, 1);
> >
> >



--
Navid.

Subject: Re: [PATCH v2] drm/exynos: fix ref count leak in mic_pre_enable



20. 6. 15. 오후 2:49에 Navid Emamdoost 이(가) 쓴 글:
> 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.
>
> Signed-off-by: Navid Emamdoost <[email protected]>
> ---
> Changes in v2:
> - reuse the unlock label and call pm_runtime_put_noidle

Picked it up.

Thanks,
Inki Dae

> ---
> ---
> drivers/gpu/drm/exynos/exynos_drm_mic.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_mic.c b/drivers/gpu/drm/exynos/exynos_drm_mic.c
> index a86abc173605..3821ea76a703 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_mic.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_mic.c
> @@ -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);
>
>