Skip to contentSkip to conversation

ASoC: core: Fix obscure leak of runtime array

PATCH In review Mark Brown 2 participants 3 messages Mar 14, 2012 – Mar 15, 2012

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/2 ASoC: core: Fix obscure leak of runtime array

We're currently not freeing card->rtd in cases where the card is unregistered before being registered - convert it to devm_kzalloc() to make sure that happens.

---
 sound/soc/soc-core.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
sound/soc/soc-core.c +4 -4
index 9a7ca0e..b0f8666 100644
@@ -1694,7 +1694,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;
 
@@ -3120,9 +3119,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];
Signature · 1 line
1.7.9.1
author
#1 lore raw

PATCH 2/2 ASoC: core: Use driver core probe deferral

In version 3.4 the driver core acquired probe deferral which is a core way of doing essentially the same thing as ASoC has been doing since forever to make sure that all the devices needed to make up the card are present without needing open coding in the subsystem.

Make basic use of this probe deferral mechanism for the cards, removing the need to handle partially instantiated cards. We should be able to remove even more code than this, though some of the checks we're currently doing should stay since they're about things like suppressing unneeded DAPM runs rather than deferring probes.

In order to avoid robustness issues with our teardown paths (which do need quite a bit of TLC) add a check for aux_devs prior to attempting to set things up, this means that we've got a reasonable idea that everything will be there before we start. As with the removal of partial instantiation support more work will be needed to make this work neatly.

---
 include/sound/soc.h  |    1 -
 sound/soc/soc-core.c |  147 +++++++++++++++++++++-----------------------------
 2 files changed, 62 insertions(+), 86 deletions(-)
include/sound/soc.h +0 -1
index b8163dd..9e238fa 100644
@@ -896,7 +896,6 @@ struct snd_soc_pcm_runtime {
 	enum snd_soc_pcm_subclass pcm_subclass;
 	struct snd_pcm_ops ops;
 
-	unsigned int complete:1;
 	unsigned int dev_registered:1;
 
 	long pmdown_time;
sound/soc/soc-core.c +62 -85

292 lines not on this page · raw message

Signature · 1 line
1.7.9.1