ASoC: atmel: Fix error handling in at91samg20ek probe()
authorMark Brown <broonie@kernel.org>
Fri, 25 Mar 2022 15:42:40 +0000 (15:42 +0000)
committerMark Brown <broonie@kernel.org>
Mon, 4 Apr 2022 13:24:10 +0000 (14:24 +0100)
The error handling in the AT91SAM9G20-EK machine driver probe did not
consistently free the SSC in error paths, sometimes immediately returning
an error rather than doing cleanup. Fix this.

Signed-off-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Link: https://lore.kernel.org/r/20220325154241.1600757-3-broonie@kernel.org
sound/soc/atmel/sam9g20_wm8731.c

index 0d639a3..d771843 100644 (file)
@@ -148,7 +148,8 @@ static int at91sam9g20ek_audio_probe(struct platform_device *pdev)
        codec_np = of_parse_phandle(np, "atmel,audio-codec", 0);
        if (!codec_np) {
                dev_err(&pdev->dev, "codec info missing\n");
-               return -EINVAL;
+               ret = -EINVAL;
+               goto err;
        }
        at91sam9g20ek_dai.codecs->of_node = codec_np;
 
@@ -159,7 +160,8 @@ static int at91sam9g20ek_audio_probe(struct platform_device *pdev)
        if (!cpu_np) {
                dev_err(&pdev->dev, "dai and pcm info missing\n");
                of_node_put(codec_np);
-               return -EINVAL;
+               ret = -EINVAL;
+               goto err;
        }
        at91sam9g20ek_dai.cpus->of_node = cpu_np;
        at91sam9g20ek_dai.platforms->of_node = cpu_np;
@@ -170,9 +172,10 @@ static int at91sam9g20ek_audio_probe(struct platform_device *pdev)
        ret = snd_soc_register_card(card);
        if (ret) {
                dev_err(&pdev->dev, "snd_soc_register_card() failed\n");
+               goto err;
        }
 
-       return ret;
+       return 0;
 
 err:
        atmel_ssc_put_audio(0);