Skip to contentSkip to conversation

ASoC: dapm: fix error path in snd_soc_dapm_new_pcm

PATCH Superseded anish kumar 2 participants 3 messages Aug 26, 2017 – Sep 2, 2017

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 ASoC: dapm: fix error path in snd_soc_dapm_new_pcm

Before freeing the memory, check if it was allcoated.

---
 sound/soc/soc-dapm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
sound/soc/soc-dapm.c +3 -2
index dcef67a..6e10a9a 100644
@@ -3907,9 +3907,10 @@ int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
 	devm_kfree(card->dev, (void *)private_value);
 outfree_link_name:
 	devm_kfree(card->dev, link_name);
-outfree_w_param:
 	for (count = 0 ; count < num_params; count++)
-		devm_kfree(card->dev, (void *)w_param_text[count]);
+            if (w_param_text[count])
+	        devm_kfree(card->dev, (void *)w_param_text[count]);
+outfree_w_param:
 	devm_kfree(card->dev, w_param_text);
 
 	return ret;
Signature · 1 line
2.10.1 (Apple Git-78)
maintainer
#1 lore raw

sound/soc/soc-dapm.c int snd_soc_dapm_new_pcm(struct snd_soc_card *card, · line 3912

Quoted 7 lines · anish kumar

Before freeing the memory, check if it was allcoated.

sound/soc/soc-dapm.c +2 -2
-outfree_w_param:
 	for (count = 0 ; count < num_params; count++)
-		devm_kfree(card->dev, (void *)w_param_text[count]);
+            if (w_param_text[count])
+	        devm_kfree(card->dev, (void *)w_param_text[count]);

There's no need to do this, devm_kfree() will handle null pointers fine.

#2 lore raw
Quoted 3 lines · Mark Brown

Thanks for reviewing.

Quoted 11 lines

sound/soc/soc-dapm.c int snd_soc_dapm_new_pcm(struct snd_soc_card *card, · line 3912

Quoted 9 lines · anish kumar

Before freeing the memory, check if it was allcoated.

sound/soc/soc-dapm.c +2 -2
-outfree_w_param:
   for (count = 0 ; count < num_params; count++)
-        devm_kfree(card->dev, (void *)w_param_text[count]);
+            if (w_param_text[count])
+            devm_kfree(card->dev, (void *)w_param_text[count]);

There's no need to do this, devm_kfree() will handle null pointers fine.

Got it. I am waiting for comments on my other patches in this series before sending again.