Skip to content

Commit e9f2a85

Browse files
tasksetmarckleinebudde
authored andcommitted
can: flexcan: fix an use-after-free in flexcan_setup_stop_mode()
The gpr_np variable is still being used in dev_dbg() after the of_node_put() call, which may result in use-after-free. Fixes: de3578c ("can: flexcan: add self wakeup support") Signed-off-by: Wen Yang <[email protected]> Cc: linux-stable <[email protected]> # >= v5.0 Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 375f755 commit e9f2a85

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/net/can/flexcan.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,10 +1437,10 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)
14371437

14381438
priv = netdev_priv(dev);
14391439
priv->stm.gpr = syscon_node_to_regmap(gpr_np);
1440-
of_node_put(gpr_np);
14411440
if (IS_ERR(priv->stm.gpr)) {
14421441
dev_dbg(&pdev->dev, "could not find gpr regmap\n");
1443-
return PTR_ERR(priv->stm.gpr);
1442+
ret = PTR_ERR(priv->stm.gpr);
1443+
goto out_put_node;
14441444
}
14451445

14461446
priv->stm.req_gpr = out_val[1];
@@ -1455,7 +1455,9 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)
14551455

14561456
device_set_wakeup_capable(&pdev->dev, true);
14571457

1458-
return 0;
1458+
out_put_node:
1459+
of_node_put(gpr_np);
1460+
return ret;
14591461
}
14601462

14611463
static const struct of_device_id flexcan_of_match[] = {

0 commit comments

Comments
 (0)