Skip to content

Commit

Permalink
rtase: Fix improper release of ring list entries in rtase_sw_reset
Browse files Browse the repository at this point in the history
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: 0796004 ("rtase: Implement net_device_ops")
Signed-off-by: Justin Lai <justinlai0215@realtek.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250306070510.18129-1-justinlai0215@realtek.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Justin Lai authored and Paolo Abeni committed Mar 11, 2025
1 parent 3121a1e commit 415f135
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/net/ethernet/realtek/rtase/rtase_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");
Expand Down

0 comments on commit 415f135

Please sign in to comment.