[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20080911.154531.136830945.davem@davemloft.net>
Date: Thu, 11 Sep 2008 15:45:31 -0700 (PDT)
From: David Miller <davem@...emloft.net>
To: mchan@...adcom.com
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH 3/3]: tg3: Use SKB DMA helper functions for TX.
From: "Michael Chan" <mchan@...adcom.com>
Date: Thu, 11 Sep 2008 10:58:41 -0700
> On Thu, 2008-09-11 at 05:03 -0700, David Miller wrote:
> > @@ -4633,12 +4624,13 @@ static int tigon3_dma_hwbug_workaround(struct tg3 *tp, struct sk_buff *skb,
> > } else {
> > /* New SKB is guaranteed to be linear. */
> > entry = *start;
> > - new_addr = pci_map_single(tp->pdev, new_skb->data, new_skb->len,
> > - PCI_DMA_TODEVICE);
> > + ret = skb_dma_map(&tp->pdev->dev, new_skb, DMA_TO_DEVICE);
> > + new_addr = skb_shinfo(new_skb)->dma_maps[0];
> > +
> > /* Make sure new skb does not cross any 4G boundaries.
> > * Drop the packet if it does.
> > */
> > - if (tg3_4g_overflow_test(new_addr, new_skb->len)) {
> > + if (ret || tg3_4g_overflow_test(new_addr, new_skb->len)) {
> > ret = -1;
>
> Looks like we are missing an unmap call here even in the original code.
> If skb_dma_map() returns 0 but overflow test fails, we need to call
> unmap here.
Good catch, I'll fix it as follows:
tg3: Fix DMA mapping leak in tigon3_dma_hwbug_workaround().
Noticed by Michael Chan.
Signed-off-by: David S. Miller <davem@...emloft.net>
---
drivers/net/tg3.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 355e8bc..1239207 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -4631,6 +4631,9 @@ static int tigon3_dma_hwbug_workaround(struct tg3 *tp, struct sk_buff *skb,
* Drop the packet if it does.
*/
if (ret || tg3_4g_overflow_test(new_addr, new_skb->len)) {
+ if (!ret)
+ skb_dma_unmap(&tp->pdev->dev, new_skb,
+ DMA_TO_DEVICE);
ret = -1;
dev_kfree_skb(new_skb);
new_skb = NULL;
--
1.5.6.5.GIT
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists