[alsa-devel] [PATCH 6/6] ASoC: samsung: Fix of-node refcount unbalance in odroid_audio_probe()

Takashi Iwai tiwai at suse.de
Tue Feb 19 16:46:52 CET 2019


odroid_audio_probe() leaves of-nodes without unreferenced after use.
Fix it by shuffling some code a bit and add the missing of_node_put()
calls accordingly.

Fixes: aba611fc4c69 ("ASoC: samsung: Add Odroid ASoC machine driver")
Cc: Krzysztof Kozlowski <krzk at kernel.org>
Cc: Sangbeom Kim <sbkim73 at samsung.com>
Cc: Sylwester Nawrocki <s.nawrocki at samsung.com>
Signed-off-by: Takashi Iwai <tiwai at suse.de>
---

Only compile-tested.  Please review carefully.  Thanks!

 sound/soc/samsung/odroid.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c
index e7b371b07230..c96fbbc8c7cc 100644
--- a/sound/soc/samsung/odroid.c
+++ b/sound/soc/samsung/odroid.c
@@ -140,14 +140,14 @@ static int odroid_audio_probe(struct platform_device *pdev)
 	card->num_links = 1;
 
 	cpu = of_get_child_by_name(dev->of_node, "cpu");
-	codec = of_get_child_by_name(dev->of_node, "codec");
-
 	link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0);
+	of_node_put(cpu);
 	if (!link->cpu_of_node) {
 		dev_err(dev, "Failed parsing cpu/sound-dai property\n");
 		return -EINVAL;
 	}
 
+	codec = of_get_child_by_name(dev->of_node, "codec");
 	ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
 	if (ret < 0)
 		goto err_put_codec_n;
@@ -186,6 +186,7 @@ static int odroid_audio_probe(struct platform_device *pdev)
 	of_node_put(link->cpu_of_node);
 err_put_codec_n:
 	snd_soc_of_put_dai_link_codecs(link);
+	of_node_put(codec);
 	return ret;
 }
 
-- 
2.16.4



More information about the Alsa-devel mailing list