Message ID | 20250224111251.1061098-9-wei.fang@nxp.com (mailing list archive) |
---|---|
State | New |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: enetc: fix some known issues | expand |
On Mon, Feb 24, 2025 at 07:12:51PM +0800, Wei Fang wrote: > There is an off-by-one issue for the err_chained_bd path, it will free > one more tx_swbd than expected. But there is no such issue for the > err_map_data path. To fix this off-by-one issue and make the two error > handling consistent, the increment of 'i' and 'count' remain in sync > and enetc_unwind_tx_frame() is called for error handling. > > Fixes: fb8629e2cbfc ("net: enetc: add support for software TSO") > Cc: stable@vger.kernel.org > Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com> > Signed-off-by: Wei Fang <wei.fang@nxp.com> > --- Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> -----Original Message----- > From: Wei Fang <wei.fang@nxp.com> > Sent: Monday, February 24, 2025 1:13 PM [...] > Subject: [PATCH v3 net 8/8] net: enetc: fix the off-by-one issue in > enetc_map_tx_tso_buffs() > > There is an off-by-one issue for the err_chained_bd path, it will free > one more tx_swbd than expected. But there is no such issue for the > err_map_data path. To fix this off-by-one issue and make the two error > handling consistent, the increment of 'i' and 'count' remain in sync > and enetc_unwind_tx_frame() is called for error handling. > > Fixes: fb8629e2cbfc ("net: enetc: add support for software TSO") > Cc: stable@vger.kernel.org > Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com> > Signed-off-by: Wei Fang <wei.fang@nxp.com> > --- Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com>
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 9801c51b6a59..2106861463e4 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -859,8 +859,13 @@ static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb err = enetc_map_tx_tso_data(tx_ring, skb, tx_swbd, txbd, tso.data, size, size == data_len); - if (err) + if (err) { + if (i == 0) + i = tx_ring->bd_count; + i--; + goto err_map_data; + } data_len -= size; count++; @@ -889,13 +894,7 @@ static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb dev_err(tx_ring->dev, "DMA map error"); err_chained_bd: - do { - tx_swbd = &tx_ring->tx_swbd[i]; - enetc_free_tx_frame(tx_ring, tx_swbd); - if (i == 0) - i = tx_ring->bd_count; - i--; - } while (count--); + enetc_unwind_tx_frame(tx_ring, count, i); return 0; }
There is an off-by-one issue for the err_chained_bd path, it will free one more tx_swbd than expected. But there is no such issue for the err_map_data path. To fix this off-by-one issue and make the two error handling consistent, the increment of 'i' and 'count' remain in sync and enetc_unwind_tx_frame() is called for error handling. Fixes: fb8629e2cbfc ("net: enetc: add support for software TSO") Cc: stable@vger.kernel.org Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Wei Fang <wei.fang@nxp.com> --- drivers/net/ethernet/freescale/enetc/enetc.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)