Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 181a6892 authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: core: Fix obscure leak of runtime array



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: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: default avatarLiam Girdwood <lrg@ti.com>
parent 4eb98f45
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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;

@@ -3112,7 +3111,8 @@ 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->rtd = devm_kzalloc(card->dev,
				 sizeof(struct snd_soc_pcm_runtime) *
				 (card->num_links + card->num_aux_devs),
				 GFP_KERNEL);
	if (card->rtd == NULL)