Skip to content

Commit

Permalink
ASoC: core: Fix obscure leak of runtime array
Browse files Browse the repository at this point in the history
We're currently not freeing card->rtd in cases where the card is
unregistered before being instantiated - convert it to devm_kzalloc() to
make sure that happens.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
  • Loading branch information
Mark Brown committed Mar 15, 2012
1 parent 4eb98f4 commit 181a689
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,6 @@ static int soc_cleanup_card_resources(struct snd_soc_card *card)

snd_soc_dapm_free(&card->dapm);

kfree(card->rtd);
snd_card_free(card->snd_card);
return 0;

Expand Down Expand Up @@ -3112,9 +3111,10 @@ int snd_soc_register_card(struct snd_soc_card *card)

soc_init_card_debugfs(card);

card->rtd = kzalloc(sizeof(struct snd_soc_pcm_runtime) *
(card->num_links + card->num_aux_devs),
GFP_KERNEL);
card->rtd = devm_kzalloc(card->dev,
sizeof(struct snd_soc_pcm_runtime) *
(card->num_links + card->num_aux_devs),
GFP_KERNEL);
if (card->rtd == NULL)
return -ENOMEM;
card->rtd_aux = &card->rtd[card->num_links];
Expand Down

0 comments on commit 181a689

Please sign in to comment.