can: flexcan: Fix OF node reference leak in flexcan_setup_stop_mode_gpr()
Subsystems (2)
PATCH 1/1 can: flexcan: Fix OF node reference leak in flexcan_setup_stop_mode_gpr()
of_find_node_by_phandle() takes a reference on the GPR node and the error path releases it through out_put_node. The success path returns before reaching that label, so the reference is leaked every time the stop mode is set up successfully, and the node can never be freed.
Release the node reference before returning.
--- drivers/net/can/flexcan/flexcan-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/can/flexcan/flexcan-core.c +1 -0
@@ -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:
Signature · 1 line
2.34.1
Marc Kleine-Budde
maintainerQuoted 8 lines · Wentao Liang
of_find_node_by_phandle()takes a reference on the GPR node and the error path releases it throughout_put_node. The success path returns before reaching that label, so the reference is leaked every time the stop mode is set up successfully, and the node can never be freed.Release the node reference before returning.
Fixes 13dfb3fa4943 ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net")
A merge commit probably has not introduced this problem...
Marc
Quoted 22 lines
Signed-off-by Wentao Liang <[email protected]>--- drivers/net/can/flexcan/flexcan-core.c | 1 + 1 file changed, 1 insertion(+)drivers/net/can/flexcan/flexcan-core.c +1
-1@@ -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
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |