[PATCH] firmware: stratix10-svc: Keep the firmware node referenced during init

From: Zhu Jun

Date: Thu Nov 12 2026 - 02:35:36 EST


of_find_matching_node() releases its starting-node reference while
walking the tree. stratix10_svc_init() passes fw_np as that starting
node and later reuses it for of_platform_populate() without retaining
a reference of its own.

Give the iterator a separate reference and keep the firmware lookup
reference until initialization finishes. Use scoped cleanup to also
release it on the no-match and population-error paths.

Fixes: 7ca5ce896524 ("firmware: add Intel Stratix10 service layer driver")
Signed-off-by: Zhu Jun <zhujun2@xxxxxxxxxxxxxxxxxxxx>
---
drivers/firmware/stratix10-svc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
index ef9d39c9ff01..0df1786b2e51 100644
--- a/drivers/firmware/stratix10-svc.c
+++ b/drivers/firmware/stratix10-svc.c
@@ -2589,15 +2589,15 @@ static struct platform_driver stratix10_svc_driver = {

static int __init stratix10_svc_init(void)
{
- struct device_node *fw_np;
+ struct device_node *fw_np __free(device_node) =
+ of_find_node_by_name(NULL, "firmware");
struct device_node *np;
int ret;

- fw_np = of_find_node_by_name(NULL, "firmware");
if (!fw_np)
return -ENODEV;

- np = of_find_matching_node(fw_np, stratix10_svc_drv_match);
+ np = of_find_matching_node(of_node_get(fw_np), stratix10_svc_drv_match);
if (!np)
return -ENODEV;

--
2.51.0