net: bcmgenet: Free skb after last Tx frag
authorDoug Berger <opendmb@gmail.com>
Fri, 14 Jul 2017 23:12:10 +0000 (16:12 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 16 Jul 2017 04:29:08 +0000 (21:29 -0700)
commitf48bed16a756f5bc0244acd581f61968f7d7c2a4
tree5f8729e923872327c2a12f47a9f3693b7874aa88
parent876dbadd53a7102e2a84afc84ea2bd3ee6dc5636
net: bcmgenet: Free skb after last Tx frag

Since the skb is attached to the first control block of a fragmented
skb it is possible that the skb could be freed when reclaiming that
control block before all fragments of the skb have been consumed by
the hardware and unmapped.

This commit introduces first_cb and last_cb pointers to the skb
control block used by the driver to keep track of which transmit
control blocks within a transmit ring are the first and last ones
associated with the skb.

It then splits the bcmgenet_free_cb() function into transmit
(bcmgenet_free_tx_cb) and receive (bcmgenet_free_rx_cb) versions
that can handle the unmapping of dma mapped memory and cleaning up
the corresponding control block structure so that the skb is only
freed after the last associated transmit control block is reclaimed.

Fixes: 1c1008c793fa ("net: bcmgenet: add main driver file")
Signed-off-by: Doug Berger <opendmb@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/genet/bcmgenet.c
drivers/net/ethernet/broadcom/genet/bcmgenet.h