ASoC: soc-core: use device_unregister() if rtd allocation failed
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tue, 30 Mar 2021 05:26:38 +0000 (14:26 +0900)
committerMark Brown <broonie@kernel.org>
Wed, 31 Mar 2021 17:02:23 +0000 (18:02 +0100)
Because soc_free_pcm_runtime(rtd) checks rtd pointer and freeing
rtd->xxx, it doesn't work correctly in case of rtd allocation failed.

We need to use device_unregister(dev) in such case.
This patch fixup it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87r1jxxldd.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-core.c

index 88694746dc11640c3db0bc37f0216c51e82af350..236e075b9e57dd27bb9e1586601379346ef82720 100644 (file)
@@ -470,8 +470,10 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
                                                 dai_link->num_codecs +
                                                 dai_link->num_platforms),
                           GFP_KERNEL);
-       if (!rtd)
-               goto free_rtd;
+       if (!rtd) {
+               device_unregister(dev);
+               return NULL;
+       }
 
        rtd->dev = dev;
        INIT_LIST_HEAD(&rtd->list);