netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] rtase: Fix improper release of ring list entries in rtase_sw_reset
@ 2025-03-06  7:05 Justin Lai
  2025-03-10  6:20 ` Simon Horman
  2025-03-11 12:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Justin Lai @ 2025-03-06  7:05 UTC (permalink / raw)
  To: kuba
  Cc: davem, edumazet, pabeni, andrew+netdev, linux-kernel, netdev,
	horms, pkshih, larry.chiu, Justin Lai

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.

Fixes: 079600489960 ("rtase: Implement net_device_ops")
Signed-off-by: Justin Lai <justinlai0215@realtek.com>
---
 drivers/net/ethernet/realtek/rtase/rtase_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
index 3bd11cb56294..2aacc1996796 100644
--- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
+++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
@@ -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");
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] rtase: Fix improper release of ring list entries in rtase_sw_reset
  2025-03-06  7:05 [PATCH net] rtase: Fix improper release of ring list entries in rtase_sw_reset Justin Lai
@ 2025-03-10  6:20 ` Simon Horman
  2025-03-11 12:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-03-10  6:20 UTC (permalink / raw)
  To: Justin Lai
  Cc: kuba, davem, edumazet, pabeni, andrew+netdev, linux-kernel,
	netdev, pkshih, larry.chiu

On Thu, Mar 06, 2025 at 03:05:10PM +0800, Justin Lai wrote:
> 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.
> 
> Fixes: 079600489960 ("rtase: Implement net_device_ops")
> Signed-off-by: Justin Lai <justinlai0215@realtek.com>

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] rtase: Fix improper release of ring list entries in rtase_sw_reset
  2025-03-06  7:05 [PATCH net] rtase: Fix improper release of ring list entries in rtase_sw_reset Justin Lai
  2025-03-10  6:20 ` Simon Horman
@ 2025-03-11 12:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-03-11 12:30 UTC (permalink / raw)
  To: Justin Lai
  Cc: kuba, davem, edumazet, pabeni, andrew+netdev, linux-kernel,
	netdev, horms, pkshih, larry.chiu

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Thu, 6 Mar 2025 15:05:10 +0800 you wrote:
> 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.
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-11 12:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-06  7:05 [PATCH net] rtase: Fix improper release of ring list entries in rtase_sw_reset Justin Lai
2025-03-10  6:20 ` Simon Horman
2025-03-11 12:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).