aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>2016-02-22 03:44:31 -0500
committerMark Brown <broonie@kernel.org>2016-02-22 05:40:06 -0500
commit513cb31120fb5a5b02d9e42eb1d0a0bf05e227c5 (patch)
tree11e1175edcf6c706f8cc3dfb020a973ad3c62808
parent92e963f50fc74041b5e9e744c330dca48e04f08d (diff)
ASoC: fix memory leak
If dai_link is already bound then we just returned and leaked rtd and rtd->codec_dais which were allocated by soc_new_pcm_runtime(). We do not need this newly allocated rtd to check if dai_link is already binded. Lets check first if it is already binded before allocating this memory. Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/soc-core.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 790ee2bf1a47..d2e62b159610 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -986,16 +986,16 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
986 986
987 dev_dbg(card->dev, "ASoC: binding %s\n", dai_link->name); 987 dev_dbg(card->dev, "ASoC: binding %s\n", dai_link->name);
988 988
989 rtd = soc_new_pcm_runtime(card, dai_link);
990 if (!rtd)
991 return -ENOMEM;
992
993 if (soc_is_dai_link_bound(card, dai_link)) { 989 if (soc_is_dai_link_bound(card, dai_link)) {
994 dev_dbg(card->dev, "ASoC: dai link %s already bound\n", 990 dev_dbg(card->dev, "ASoC: dai link %s already bound\n",
995 dai_link->name); 991 dai_link->name);
996 return 0; 992 return 0;
997 } 993 }
998 994
995 rtd = soc_new_pcm_runtime(card, dai_link);
996 if (!rtd)
997 return -ENOMEM;
998
999 cpu_dai_component.name = dai_link->cpu_name; 999 cpu_dai_component.name = dai_link->cpu_name;
1000 cpu_dai_component.of_node = dai_link->cpu_of_node; 1000 cpu_dai_component.of_node = dai_link->cpu_of_node;
1001 cpu_dai_component.dai_name = dai_link->cpu_dai_name; 1001 cpu_dai_component.dai_name = dai_link->cpu_dai_name;