public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] firmware: Avoid leak OF node on error
@ 2022-05-23 11:13 cgel.zte
  2022-05-23 11:55 ` Johan Hovold
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-05-23 11:13 UTC (permalink / raw)
  To: dinguyen; +Cc: linux-kernel, Minghao Chi, Zeal Robot

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

The OF node should be put before returning error in stratix10_svc_init(),
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/firmware/stratix10-svc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
index 14663f671323..3facd5dfb617 100644
--- a/drivers/firmware/stratix10-svc.c
+++ b/drivers/firmware/stratix10-svc.c
@@ -1109,10 +1109,10 @@ static int __init stratix10_svc_init(void)
 		return -ENODEV;
 
 	np = of_find_matching_node(fw_np, stratix10_svc_drv_match);
+	of_node_put(np);
 	if (!np)
 		return -ENODEV;
 
-	of_node_put(np);
 	ret = of_platform_populate(fw_np, stratix10_svc_drv_match, NULL, NULL);
 	if (ret)
 		return ret;
-- 
2.25.1



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

end of thread, other threads:[~2022-05-23 11:55 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:13 [PATCH] firmware: Avoid leak OF node on error cgel.zte
2022-05-23 11:55 ` Johan Hovold

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