diff options
author | Ivan Vecera <ivecera@redhat.com> | 2013-11-06 08:02:36 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-11-07 19:09:44 -0500 |
commit | 85aec73d595b8847f9c4ea571deb127913f0d508 (patch) | |
tree | e4d2fcdd4cb1d6e1dd93f835cfc708e7476a4ed0 /drivers/net/ethernet/broadcom/tg3.c | |
parent | 28fb96552472d8ef6197f6dc4c768cf8a64c570d (diff) |
tg3: avoid double-freeing of rx data memory
If build_skb fails the memory associated with the ring buffer is freed but
the ri->data member is not zeroed in this case. This causes a double-free
of this memory in tg3_free_rings->... path. The patch moves this block after
setting ri->data to NULL.
It would be nice to fix this bug also in stable >= v3.4 trees.
Cc: Nithin Nayak Sujir <nsujir@broadcom.com>
Cc: Michael Chan <mchan@broadcom.com>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Acked-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/broadcom/tg3.c')
-rw-r--r-- | drivers/net/ethernet/broadcom/tg3.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 819d87c281bf..00c5be8c55b8 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c | |||
@@ -6862,12 +6862,6 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget) | |||
6862 | pci_unmap_single(tp->pdev, dma_addr, skb_size, | 6862 | pci_unmap_single(tp->pdev, dma_addr, skb_size, |
6863 | PCI_DMA_FROMDEVICE); | 6863 | PCI_DMA_FROMDEVICE); |
6864 | 6864 | ||
6865 | skb = build_skb(data, frag_size); | ||
6866 | if (!skb) { | ||
6867 | tg3_frag_free(frag_size != 0, data); | ||
6868 | goto drop_it_no_recycle; | ||
6869 | } | ||
6870 | skb_reserve(skb, TG3_RX_OFFSET(tp)); | ||
6871 | /* Ensure that the update to the data happens | 6865 | /* Ensure that the update to the data happens |
6872 | * after the usage of the old DMA mapping. | 6866 | * after the usage of the old DMA mapping. |
6873 | */ | 6867 | */ |
@@ -6875,6 +6869,12 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget) | |||
6875 | 6869 | ||
6876 | ri->data = NULL; | 6870 | ri->data = NULL; |
6877 | 6871 | ||
6872 | skb = build_skb(data, frag_size); | ||
6873 | if (!skb) { | ||
6874 | tg3_frag_free(frag_size != 0, data); | ||
6875 | goto drop_it_no_recycle; | ||
6876 | } | ||
6877 | skb_reserve(skb, TG3_RX_OFFSET(tp)); | ||
6878 | } else { | 6878 | } else { |
6879 | tg3_recycle_rx(tnapi, tpr, opaque_key, | 6879 | tg3_recycle_rx(tnapi, tpr, opaque_key, |
6880 | desc_idx, *post_ptr); | 6880 | desc_idx, *post_ptr); |