diff mbox series

ASoC: pcm512x: Fix unbalanced regulator enable call in probe error path

Message ID 20200220202956.29233-1-hias@horus.com (mailing list archive)
State Accepted
Commit ac0a68997935c4acb92eaae5ad8982e0bb432d56
Headers show
Series ASoC: pcm512x: Fix unbalanced regulator enable call in probe error path | expand

Commit Message

Matthias Reichl Feb. 20, 2020, 8:29 p.m. UTC
When we get a clock error during probe we have to call
regulator_bulk_disable before bailing out, otherwise we trigger
a warning in regulator_put.

Fix this by using "goto err" like in the error cases above.

Fixes: 5a3af1293194d ("ASoC: pcm512x: Add PCM512x driver")
Signed-off-by: Matthias Reichl <hias@horus.com>
---
 sound/soc/codecs/pcm512x.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Pierre-Louis Bossart Feb. 20, 2020, 8:54 p.m. UTC | #1
On 2/20/20 2:29 PM, Matthias Reichl wrote:
> When we get a clock error during probe we have to call
> regulator_bulk_disable before bailing out, otherwise we trigger
> a warning in regulator_put.
> 
> Fix this by using "goto err" like in the error cases above.
> 
> Fixes: 5a3af1293194d ("ASoC: pcm512x: Add PCM512x driver")
> Signed-off-by: Matthias Reichl <hias@horus.com>

LGTM:

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

> ---
>   sound/soc/codecs/pcm512x.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
> index 861210f6bf4fd..4cbef9affffda 100644
> --- a/sound/soc/codecs/pcm512x.c
> +++ b/sound/soc/codecs/pcm512x.c
> @@ -1564,13 +1564,15 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap)
>   	}
>   
>   	pcm512x->sclk = devm_clk_get(dev, NULL);
> -	if (PTR_ERR(pcm512x->sclk) == -EPROBE_DEFER)
> -		return -EPROBE_DEFER;
> +	if (PTR_ERR(pcm512x->sclk) == -EPROBE_DEFER) {
> +		ret = -EPROBE_DEFER;
> +		goto err;
> +	}
>   	if (!IS_ERR(pcm512x->sclk)) {
>   		ret = clk_prepare_enable(pcm512x->sclk);
>   		if (ret != 0) {
>   			dev_err(dev, "Failed to enable SCLK: %d\n", ret);
> -			return ret;
> +			goto err;
>   		}
>   	}
>   
>
diff mbox series

Patch

diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index 861210f6bf4fd..4cbef9affffda 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -1564,13 +1564,15 @@  int pcm512x_probe(struct device *dev, struct regmap *regmap)
 	}
 
 	pcm512x->sclk = devm_clk_get(dev, NULL);
-	if (PTR_ERR(pcm512x->sclk) == -EPROBE_DEFER)
-		return -EPROBE_DEFER;
+	if (PTR_ERR(pcm512x->sclk) == -EPROBE_DEFER) {
+		ret = -EPROBE_DEFER;
+		goto err;
+	}
 	if (!IS_ERR(pcm512x->sclk)) {
 		ret = clk_prepare_enable(pcm512x->sclk);
 		if (ret != 0) {
 			dev_err(dev, "Failed to enable SCLK: %d\n", ret);
-			return ret;
+			goto err;
 		}
 	}