Skip to content

Commit bf8c675

Browse files
nikita-youshgregkh
authored andcommitted
net: renesas: rswitch: avoid use-after-put for a device tree node
[ Upstream commit 66b7e9f ] The device tree node saved in the rswitch_device structure is used at several driver locations. So passing this node to of_node_put() after the first use is wrong. Move of_node_put() for this node to exit paths. Fixes: b46f1e5 ("net: renesas: rswitch: Simplify struct phy * handling") Signed-off-by: Nikita Yushchenko <[email protected]> Reviewed-by: Yoshihiro Shimoda <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 78aa0aa commit bf8c675

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/ethernet/renesas/rswitch.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,6 @@ static int rswitch_device_alloc(struct rswitch_private *priv, unsigned int index
18191819
rdev->np_port = rswitch_get_port_node(rdev);
18201820
rdev->disabled = !rdev->np_port;
18211821
err = of_get_ethdev_address(rdev->np_port, ndev);
1822-
of_node_put(rdev->np_port);
18231822
if (err) {
18241823
if (is_valid_ether_addr(rdev->etha->mac_addr))
18251824
eth_hw_addr_set(ndev, rdev->etha->mac_addr);
@@ -1849,6 +1848,7 @@ static int rswitch_device_alloc(struct rswitch_private *priv, unsigned int index
18491848

18501849
out_rxdmac:
18511850
out_get_params:
1851+
of_node_put(rdev->np_port);
18521852
netif_napi_del(&rdev->napi);
18531853
free_netdev(ndev);
18541854

@@ -1862,6 +1862,7 @@ static void rswitch_device_free(struct rswitch_private *priv, unsigned int index
18621862

18631863
rswitch_txdmac_free(ndev);
18641864
rswitch_rxdmac_free(ndev);
1865+
of_node_put(rdev->np_port);
18651866
netif_napi_del(&rdev->napi);
18661867
free_netdev(ndev);
18671868
}

0 commit comments

Comments
 (0)