mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
net: stmmac: fix device node reference leaks in stmmac_mtl_setup()
In stmmac_mtl_setup(), q_node is shared across the RX and TX queue parsing loops. When the RX queue loop breaks early because the number of parsed queues reaches plat->rx_queues_to_use, q_node retains an acquired reference count. If the error check passes (queue == plat->rx_queues_to_use), execution proceeds directly to the TX queue loop, where of_get_next_child() immediately overwrites q_node with the first TX child, permanently leaking the retained RX child device node reference. Switch both loops to for_each_child_of_node_scoped() so child node references are automatically dropped upon loop exit or early break, and remove the now-unnecessary function-scoped q_node variable and its manual of_node_put() at the exit label. Signed-off-by: Md Rabbani <rabbanyhmm@gmail.com> Link: https://patch.msgid.link/20260821055718.57-1-rabbanyhmm@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
af20e269f7
commit
317fe168f4
|
|
@ -130,7 +130,6 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
|
|||
static int stmmac_mtl_setup(struct platform_device *pdev,
|
||||
struct plat_stmmacenet_data *plat)
|
||||
{
|
||||
struct device_node *q_node;
|
||||
struct device_node *rx_node;
|
||||
struct device_node *tx_node;
|
||||
u8 queue = 0;
|
||||
|
|
@ -169,7 +168,7 @@ static int stmmac_mtl_setup(struct platform_device *pdev,
|
|||
plat->rx_sched_algorithm = MTL_RX_ALGORITHM_SP;
|
||||
|
||||
/* Processing individual RX queue config */
|
||||
for_each_child_of_node(rx_node, q_node) {
|
||||
for_each_child_of_node_scoped(rx_node, q_node) {
|
||||
if (queue >= plat->rx_queues_to_use)
|
||||
break;
|
||||
|
||||
|
|
@ -227,7 +226,7 @@ static int stmmac_mtl_setup(struct platform_device *pdev,
|
|||
queue = 0;
|
||||
|
||||
/* Processing individual TX queue config */
|
||||
for_each_child_of_node(tx_node, q_node) {
|
||||
for_each_child_of_node_scoped(tx_node, q_node) {
|
||||
if (queue >= plat->tx_queues_to_use)
|
||||
break;
|
||||
|
||||
|
|
@ -276,7 +275,6 @@ static int stmmac_mtl_setup(struct platform_device *pdev,
|
|||
out:
|
||||
of_node_put(rx_node);
|
||||
of_node_put(tx_node);
|
||||
of_node_put(q_node);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user