[PATCH] can: flexcan: fix device node reference leak in stop mode setup

From: Wentao Liang

Date: Tue Nov 03 2026 - 06:08:44 EST


of_find_node_by_phandle() returns a device node with an incremented
reference count. flexcan_setup_stop_mode_gpr() drops it only when
syscon_node_to_regmap() fails, so a successful probe of a controller
using the GPR stop mode leaks one reference on the GPR node.

Release the reference on the success path as well.

Fixes: de3578c198c6 ("can: flexcan: add self wakeup support")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/net/can/flexcan/flexcan-core.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
index 86b40abe9e76..30ae7c344a05 100644
--- a/drivers/net/can/flexcan/flexcan-core.c
+++ b/drivers/net/can/flexcan/flexcan-core.c
@@ -1986,6 +1986,7 @@ static int flexcan_setup_stop_mode_gpr(struct platform_device *pdev)
"gpr %s req_gpr=0x02%x req_bit=%u\n",
gpr_np->full_name, priv->stm.req_gpr, priv->stm.req_bit);

+ of_node_put(gpr_np);
return 0;

out_put_node:
--
2.34.1