diff mbox series

arch: sparc: add missing of_node_put before return

Message ID 1639388586-63750-1-git-send-email-wangqing@vivo.com
State New
Headers show
Series arch: sparc: add missing of_node_put before return | expand

Commit Message

王擎 Dec. 13, 2021, 9:43 a.m. UTC
From: Wang Qing <wangqing@vivo.com>

Fix following coccicheck warning:
WARNING: Function "for_each_node_by_type" 
should have of_node_put() before return.

Early exits from for_each_node_by_type should decrement the
node reference counter.

Signed-off-by: Wang Qing <wangqing@vivo.com>
---
 arch/sparc/kernel/prom_64.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arch/sparc/kernel/prom_64.c b/arch/sparc/kernel/prom_64.c
index f883a50..ed3e987
--- a/arch/sparc/kernel/prom_64.c
+++ b/arch/sparc/kernel/prom_64.c
@@ -460,8 +460,10 @@  static void *of_iterate_over_cpus(void *(*func)(struct device_node *, int, int),
 		}
 #endif
 		ret = func(dp, cpuid, arg);
-		if (ret)
+		if (ret) {
+			of_node_put(dp);
 			return ret;
+		}
 	}
 	return NULL;
 }