]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: bcmgenet: fix off-by-one in bcmgenet_put_txcb
authorJustin Chen <justin.chen@broadcom.com>
Mon, 6 Apr 2026 17:57:54 +0000 (10:57 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 10 Apr 2026 03:19:45 +0000 (20:19 -0700)
The write_ptr points to the next open tx_cb. We want to return the
tx_cb that gets rewinded, so we must rewind the pointer first then
return the tx_cb that it points to. That way the txcb can be correctly
cleaned up.

Fixes: 876dbadd53a7 ("net: bcmgenet: Fix unmapping of fragments in bcmgenet_xmit()")
Signed-off-by: Justin Chen <justin.chen@broadcom.com>
Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Link: https://patch.msgid.link/20260406175756.134567-2-justin.chen@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/genet/bcmgenet.c

index 482a31e7b72bc310651d76ae3a12f9b801fe30cb..0f6e4baba25b92be1c2bcdc8fce74412c104f653 100644 (file)
@@ -1819,15 +1819,15 @@ static struct enet_cb *bcmgenet_put_txcb(struct bcmgenet_priv *priv,
 {
        struct enet_cb *tx_cb_ptr;
 
-       tx_cb_ptr = ring->cbs;
-       tx_cb_ptr += ring->write_ptr - ring->cb_ptr;
-
        /* Rewinding local write pointer */
        if (ring->write_ptr == ring->cb_ptr)
                ring->write_ptr = ring->end_ptr;
        else
                ring->write_ptr--;
 
+       tx_cb_ptr = ring->cbs;
+       tx_cb_ptr += ring->write_ptr - ring->cb_ptr;
+
        return tx_cb_ptr;
 }