Skip to contentSkip to conversation

ASoC: bcm: add missing call to of_node_put()

PATCH In review Yang Li 2 participants 2 messages Mar 8, 2021

Subsystems (3)
lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 ASoC: bcm: add missing call to of_node_put()

In one of the error paths of the for_each_child_of_node() loop, add missing call to of_node_put().

Fix the following coccicheck warning:
./sound/soc/bcm/cygnus-ssp.c:1346:1-33: WARNING: Function "for_each_available_child_of_node" should have of_node_put() before return around line 1352.

---
 sound/soc/bcm/cygnus-ssp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/bcm/cygnus-ssp.c +3 -1
index 6e634b4..aa16a23 100644
@@ -1348,8 +1348,10 @@ static int cygnus_ssp_probe(struct platform_device *pdev)
 					&cygnus_ssp_dai[active_port_count]);
 
 		/* negative is err, 0 is active and good, 1 is disabled */
-		if (err < 0)
+		if (err < 0) {
+			of_node_put(child_node);
 			return err;
+		}
 		else if (!err) {
 			dev_dbg(dev, "Activating DAI: %s\n",
 				cygnus_ssp_dai[active_port_count].name);
Signature · 1 line
1.8.3.1
#1 lore raw

Hi Yang,

Quoted 19 lines · Yang Li

In one of the error paths of the for_each_child_of_node() loop, add missing call to of_node_put().

Fix the following coccicheck warning:
./sound/soc/bcm/cygnus-ssp.c:1346:1-33: WARNING: Function "for_each_available_child_of_node" should have of_node_put() before return around line 1352.

---
 sound/soc/bcm/cygnus-ssp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/bcm/cygnus-ssp.c +0 -0
index 6e634b4..aa16a23 100644

sound/soc/bcm/cygnus-ssp.c static int cygnus_ssp_probe(struct platform_device *pdev) · line 1352

Quoted 6 lines
sound/soc/bcm/cygnus-ssp.c +2 -1
@@ -1348,8 +1348,10 @@ static int cygnus_ssp_probe(struct platform_device *pdev)
 					&cygnus_ssp_dai[active_port_count]);
 
 		/* negative is err, 0 is active and good, 1 is disabled */
-		if (err < 0)
+		if (err < 0) {
+			of_node_put(child_node);

If such is needed in probe what about the other child_nodes in for_each_child_of_node loop that have already been parsed and succeeded. Do they need additional cleanup as well?

Quoted 6 lines
sound/soc/bcm/cygnus-ssp.c +1 -0
 			return err;
+		}
 		else if (!err) {
 			dev_dbg(dev, "Activating DAI: %s\n",
 				cygnus_ssp_dai[active_port_count].name);