mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] soc/tegra: Avoid leak OF node on error
@ 2022-05-23 11:12 cgel.zte
  2022-05-23 11:54 ` Johan Hovold
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-05-23 11:12 UTC (permalink / raw)
  To: thierry.reding
  Cc: jonathanh, linux-tegra, linux-kernel, Minghao Chi, Zeal Robot

From: Minghao Chi <chi.minghao@zte.com.cn>

The OF node should be put before returning error in tegra_init_soc(),
otherwise node's refcount will be leaked.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
---
 drivers/soc/tegra/fuse/fuse-tegra.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
index b0a8405dbdb1..ab3e4dc6dc6e 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
@@ -612,11 +612,10 @@ static int __init tegra_init_soc(void)
 
 	/* make sure we're running on Tegra */
 	np = of_find_matching_node(NULL, tegra_fuse_match);
+	of_node_put(np);
 	if (!np)
 		return 0;
 
-	of_node_put(np);
-
 	soc = tegra_soc_device_register();
 	if (IS_ERR(soc)) {
 		pr_err("failed to register SoC device: %ld\n", PTR_ERR(soc));
-- 
2.25.1



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

end of thread, other threads:[~2022-05-23 11:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-23 11:12 [PATCH] soc/tegra: Avoid leak OF node on error cgel.zte
2022-05-23 11:54 ` Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®