rtase: Fix improper release of ring list entries in rtase_sw_reset
Subsystems (3)
Justin Lai
maintainerPATCH 1/1 rtase: Fix improper release of ring list entries in rtase_sw_reset
Since rtase_init_ring, which is called within rtase_sw_reset, adds ring entries already present in the ring list back into the list, it causes the ring list to form a cycle. This results in list_for_each_entry_safe failing to find an endpoint during traversal, leading to an error. Therefore, it is necessary to remove the previously added ring_list nodes before calling rtase_init_ring.
--- drivers/net/ethernet/realtek/rtase/rtase_main.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/ethernet/realtek/rtase/rtase_main.c +10 -0
@@ -1501,7 +1501,10 @@ static void rtase_wait_for_quiescence(const struct net_device *dev)static void rtase_sw_reset (struct net_device *dev) {struct rtase_private *tp =netdev_priv (dev); +struct rtase_ring *ring, *tmp; +struct rtase_int_vector *ivec;int ret; +u32 i;netif_stop_queue (dev);netif_carrier_off (dev);
@@ -1512,6 +1515,13 @@ static void rtase_sw_reset(struct net_device *dev)rtase_tx_clear (tp);rtase_rx_clear (tp); +for (i =0 ; i < tp->int_nums; i++) { + ivec = &tp->int_vector[i]; +list_for_each_entry_safe (ring, tmp, &ivec->ring_list, + ring_entry) +list_del (&ring->ring_entry); + } + ret =rtase_init_ring (dev);if (ret) {netdev_err (dev,"unable to init ring\n" );
Signature · 1 line
2.34.1
Quoted 9 lines · Justin Lai
Since
rtase_init_ring, which is called withinrtase_sw_reset, adds ring entries already present in the ring list back into the list, it causes the ring list to form a cycle. This results inlist_for_each_entry_safefailing to find an endpoint during traversal, leading to an error. Therefore, it is necessary to remove the previously addedring_listnodes before callingrtase_init_ring.Fixes 079600489960 ("rtase: Implement net_device_ops")Signed-off-by Justin Lai <[email protected]>
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 8 lines · On Thu, 6 Mar 2025 15:05:10 +0800 you wrote:
Since
rtase_init_ring, which is called withinrtase_sw_reset, adds ring entries already present in the ring list back into the list, it causes the ring list to form a cycle. This results inlist_for_each_entry_safefailing to find an endpoint during traversal, leading to an error. Therefore, it is necessary to remove the previously addedring_listnodes before callingrtase_init_ring.[...]
Here is the summary with links:
- [net] rtase: Fix improper release of ring list entries in rtase_sw_reset
https://git.kernel.org/netdev/net/c/415f135ace7f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html