firmware: Avoid leak OF node on error
PATCH 1/1 firmware: Avoid leak OF node on error
From: Minghao Chi <[email protected]>
The OF node should be put before returning error in stratix10_svc_init(), otherwise node's refcount will be leaked.
Reported-by Zeal Robot <[email protected]>
Signed-off-by Minghao Chi <[email protected]>
--- drivers/firmware/stratix10-svc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/stratix10-svc.c +1 -1
@@ -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;
Signature · 1 line
2.25.1
Johan Hovold
NAKQuoted 17 lines · On Mon, May 23, 2022 at 11:13:23AM +0000, [email protected] wrote:
From: Minghao Chi <[email protected]>
The OF node should be put before returning error in
stratix10_svc_init(), otherwise node's refcount will be leaked.Reported-by Zeal Robot <[email protected]>Signed-off-by Minghao Chi <[email protected]>--- drivers/firmware/stratix10-svc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/firmware/stratix10-svc.c +0
-0@@ -1109,10 +1109,10 @@ static int __init stratix10_svc_init(void)return -ENODEV ;
drivers/firmware/stratix10-svc.c static int __init stratix10_svc_init(void) · line 1118
Quoted 10 lines
drivers/firmware/stratix10-svc.c +1
-1np =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;
NAK, please just stop