]> git.openfabrics.org - ~shefty/rdma-dev.git/blobdiff - sound/soc/soc-core.c
ASoC: core: fix the memory leak in case of device_add() failure
[~shefty/rdma-dev.git] / sound / soc / soc-core.c
index 29046e750ad774b94b3aab787cab7630c8f71833..f7551c1c827ce76c16adbb9425b58fe23fe52f1c 100644 (file)
@@ -1255,6 +1255,8 @@ static int soc_post_component_init(struct snd_soc_card *card,
        INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].fe_clients);
        ret = device_add(rtd->dev);
        if (ret < 0) {
+               /* calling put_device() here to free the rtd->dev */
+               put_device(rtd->dev);
                dev_err(card->dev,
                        "ASoC: failed to register runtime device: %d\n", ret);
                return ret;