Message ID | 20241105163545.33585-2-wahrenst@gmx.net (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [1/2,net,V2] net: vertexcom: mse102x: Fix possible double free of TX skb | expand |
On Tue, 5 Nov 2024 17:35:45 +0100 Stefan Wahren wrote: > + mse->ndev->stats.tx_bytes += max_t(unsigned int, > + txb->len, ETH_ZLEN); Is this enough? skb->len will include 2 bytes added by mse102x_push_header() and 2 added by mse102x_put_footer() (unless we went to skb_copy_expand(), which is very likely) May be easier to save the skb->len before calling mse102x_tx_pkt_spi()
diff --git a/drivers/net/ethernet/vertexcom/mse102x.c b/drivers/net/ethernet/vertexcom/mse102x.c index 2c37957478fb..1fffae6596de 100644 --- a/drivers/net/ethernet/vertexcom/mse102x.c +++ b/drivers/net/ethernet/vertexcom/mse102x.c @@ -443,7 +443,8 @@ static void mse102x_tx_work(struct work_struct *work) if (ret) { mse->ndev->stats.tx_dropped++; } else { - mse->ndev->stats.tx_bytes += txb->len; + mse->ndev->stats.tx_bytes += max_t(unsigned int, + txb->len, ETH_ZLEN); mse->ndev->stats.tx_packets++; }
The tx_bytes should consider the actual size of the Ethernet frames without the SPI encapsulation. But we still need to take care of Ethernet padding. Fixes: 2f207cbf0dd4 ("net: vertexcom: Add MSE102x SPI support") Signed-off-by: Stefan Wahren <wahrenst@gmx.net> --- drivers/net/ethernet/vertexcom/mse102x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.34.1