diff mbox series

[2/3] ASoC: wm8997: Fix PM disable depth imbalance on error

Message ID 20201111041326.1257558-3-zhangqilong3@huawei.com (mailing list archive)
State New, archived
Headers show
Series Fix PM disable depth imbalance on error | expand

Commit Message

Zhang Qilong Nov. 11, 2020, 4:13 a.m. UTC
The pm_runtime_enable will increase power disable depth. Thus
a pairing decrement is needed on the error handling path to
keep it balanced according to context.

Fixes: 31833ead95c2c ("ASoC: arizona: Move request of speaker IRQs into bus probe")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 sound/soc/codecs/wm8997.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Richard Fitzgerald Nov. 11, 2020, 9:56 a.m. UTC | #1
On 11/11/2020 04:13, Zhang Qilong wrote:
> The pm_runtime_enable will increase power disable depth. Thus
> a pairing decrement is needed on the error handling path to
> keep it balanced according to context.
> 
> Fixes: 31833ead95c2c ("ASoC: arizona: Move request of speaker IRQs into bus probe")
> Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
> ---
>   sound/soc/codecs/wm8997.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c
> index 37e4bb3dbd8a..744104edb2eb 100644
> --- a/sound/soc/codecs/wm8997.c
> +++ b/sound/soc/codecs/wm8997.c
> @@ -1163,10 +1163,10 @@ static int wm8997_probe(struct platform_device *pdev)
>   
>   	ret = arizona_init_vol_limit(arizona);
>   	if (ret < 0)
> -		return ret;
> +		goto err_pm_disable;
>   	ret = arizona_init_spk_irqs(arizona);
>   	if (ret < 0)
> -		return ret;
> +		goto err_pm_disable;
>   
>   	ret = devm_snd_soc_register_component(&pdev->dev,
>   					      &soc_component_dev_wm8997,
> @@ -1176,9 +1176,14 @@ static int wm8997_probe(struct platform_device *pdev)
>   		dev_err(&pdev->dev, "Failed to register component: %d\n", ret);
>   		goto err_spk_irqs;
>   	}
> +	arizona_free_spk_irqs(arizona);

Should not be freeing speaker irqs on successful probe.
This looks like an existing bug in the driver where the return 0 was
missing so it would always exit through the error path.

> +
> +	return ret;
>   
>   err_spk_irqs:
>   	arizona_free_spk_irqs(arizona);
> +err_pm_disable:
> +	pm_runtime_disable(&pdev->dev);
>   
>   	return ret;
>   }
>
Zhang Qilong Nov. 11, 2020, 10:15 a.m. UTC | #2
> 
> On 11/11/2020 04:13, Zhang Qilong wrote:
> > The pm_runtime_enable will increase power disable depth. Thus a
> > pairing decrement is needed on the error handling path to keep it
> > balanced according to context.
> >
> > Fixes: 31833ead95c2c ("ASoC: arizona: Move request of speaker IRQs
> > into bus probe")
> > Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
> > ---
> >   sound/soc/codecs/wm8997.c | 9 +++++++--
> >   1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c
> > index 37e4bb3dbd8a..744104edb2eb 100644
> > --- a/sound/soc/codecs/wm8997.c
> > +++ b/sound/soc/codecs/wm8997.c
> > @@ -1163,10 +1163,10 @@ static int wm8997_probe(struct
> platform_device
> > *pdev)
> >
> >   	ret = arizona_init_vol_limit(arizona);
> >   	if (ret < 0)
> > -		return ret;
> > +		goto err_pm_disable;
> >   	ret = arizona_init_spk_irqs(arizona);
> >   	if (ret < 0)
> > -		return ret;
> > +		goto err_pm_disable;
> >
> >   	ret = devm_snd_soc_register_component(&pdev->dev,
> >   					      &soc_component_dev_wm8997, @@
> -1176,9 +1176,14 @@ static
> > int wm8997_probe(struct platform_device *pdev)
> >   		dev_err(&pdev->dev, "Failed to register component: %d\n", ret);
> >   		goto err_spk_irqs;
> >   	}
> > +	arizona_free_spk_irqs(arizona);
> 
> Should not be freeing speaker irqs on successful probe.
> This looks like an existing bug in the driver where the return 0 was missing so it
> would always exit through the error path.

Yes, You are right, I had a little doubts here before, it should be freed when it is be removed. I will fix it next version.

Thans,
Zhang


> 
> > +
> > +	return ret;
> >
> >   err_spk_irqs:
> >   	arizona_free_spk_irqs(arizona);
> > +err_pm_disable:
> > +	pm_runtime_disable(&pdev->dev);
> >
> >   	return ret;
> >   }
> >
diff mbox series

Patch

diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c
index 37e4bb3dbd8a..744104edb2eb 100644
--- a/sound/soc/codecs/wm8997.c
+++ b/sound/soc/codecs/wm8997.c
@@ -1163,10 +1163,10 @@  static int wm8997_probe(struct platform_device *pdev)
 
 	ret = arizona_init_vol_limit(arizona);
 	if (ret < 0)
-		return ret;
+		goto err_pm_disable;
 	ret = arizona_init_spk_irqs(arizona);
 	if (ret < 0)
-		return ret;
+		goto err_pm_disable;
 
 	ret = devm_snd_soc_register_component(&pdev->dev,
 					      &soc_component_dev_wm8997,
@@ -1176,9 +1176,14 @@  static int wm8997_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "Failed to register component: %d\n", ret);
 		goto err_spk_irqs;
 	}
+	arizona_free_spk_irqs(arizona);
+
+	return ret;
 
 err_spk_irqs:
 	arizona_free_spk_irqs(arizona);
+err_pm_disable:
+	pm_runtime_disable(&pdev->dev);
 
 	return ret;
 }