devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of: Add missing of_node_put() before return
@ 2022-04-21 12:23 Wan Jiabing
  2022-04-21 12:34 ` Rob Herring
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Wan Jiabing @ 2022-04-21 12:23 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, devicetree, linux-kernel; +Cc: kael_w, Wan Jiabing

Fix the following coccicheck error:
drivers/of/platform.c:554:2-23: WARNING: Function "for_each_node_by_type"
should have of_node_put() before return around line 560.

Early exits from for_each_node_by_type() should decrement the node
reference counter.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
---
 drivers/of/platform.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 2dff3a3d137c..3c7ca6671716 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -556,8 +556,10 @@ static int __init of_platform_default_populate_init(void)
 			    !of_get_property(node, "linux,boot-display", NULL))
 				continue;
 			dev = of_platform_device_create(node, "of-display", NULL);
-			if (WARN_ON(!dev))
+			if (WARN_ON(!dev)) {
+				of_node_put(node)
 				return -ENOMEM;
+			}
 			boot_display = node;
 			break;
 		}
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-21 19:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-21 12:23 [PATCH] of: Add missing of_node_put() before return Wan Jiabing
2022-04-21 12:34 ` Rob Herring
2022-04-21 19:34 ` kernel test robot
2022-04-21 19:54 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).