[PATCH 5.18 0907/1095] ASoC: audio-graph-card2: Add of_node_put() in fail path

From: Greg Kroah-Hartman
Date: Mon Aug 15 2022 - 18:48:52 EST


From: Liang He <windhl@xxxxxxx>

[ Upstream commit 8ebc4dd8250fd1cb5da2869c0fe6ae3686fe41e9 ]

In asoc_simple_parse_dai(), we should call of_node_put() for the
reference returned by of_graph_get_port_parent() in fail path.

Fixes: 6e5f68fe3f2d ("ASoC: add Audio Graph Card2 driver")
Signed-off-by: Liang He <windhl@xxxxxxx>
Link: https://lore.kernel.org/r/20220722141801.1304854-1-windhl@xxxxxxx
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
sound/soc/generic/audio-graph-card2.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c
index ba3551d9a040..da782403316f 100644
--- a/sound/soc/generic/audio-graph-card2.c
+++ b/sound/soc/generic/audio-graph-card2.c
@@ -445,8 +445,10 @@ static int asoc_simple_parse_dai(struct device_node *ep,
* if he unbinded CPU or Codec.
*/
ret = snd_soc_get_dai_name(&args, &dlc->dai_name);
- if (ret < 0)
+ if (ret < 0) {
+ of_node_put(node);
return ret;
+ }

dlc->of_node = node;

--
2.35.1