Skip to content

Commit 66b7e9f

Browse files
nikita-youshkuba-moo
authored andcommitted
net: renesas: rswitch: avoid use-after-put for a device tree node
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 <nikita.yoush@cogentembedded.com> Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Link: https://patch.msgid.link/20241208095004.69468-5-nikita.yoush@cogentembedded.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent bb61732 commit 66b7e9f

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
@@ -1891,7 +1891,6 @@ static int rswitch_device_alloc(struct rswitch_private *priv, unsigned int index
18911891
rdev->np_port = rswitch_get_port_node(rdev);
18921892
rdev->disabled = !rdev->np_port;
18931893
err = of_get_ethdev_address(rdev->np_port, ndev);
1894-
of_node_put(rdev->np_port);
18951894
if (err) {
18961895
if (is_valid_ether_addr(rdev->etha->mac_addr))
18971896
eth_hw_addr_set(ndev, rdev->etha->mac_addr);
@@ -1921,6 +1920,7 @@ static int rswitch_device_alloc(struct rswitch_private *priv, unsigned int index
19211920

19221921
out_rxdmac:
19231922
out_get_params:
1923+
of_node_put(rdev->np_port);
19241924
netif_napi_del(&rdev->napi);
19251925
free_netdev(ndev);
19261926

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

19351935
rswitch_txdmac_free(ndev);
19361936
rswitch_rxdmac_free(ndev);
1937+
of_node_put(rdev->np_port);
19371938
netif_napi_del(&rdev->napi);
19381939
free_netdev(ndev);
19391940
}

0 commit comments

Comments
 (0)