From: David Miller <davem@davemloft.net>
To: mchan@broadcom.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 3/3]: tg3: Use SKB DMA helper functions for TX.
Date: Thu, 11 Sep 2008 15:45:31 -0700 (PDT) [thread overview]
Message-ID: <20080911.154531.136830945.davem@davemloft.net> (raw)
In-Reply-To: <1221155921.12785.9.camel@HP1>
From: "Michael Chan" <mchan@broadcom.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@davemloft.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
prev parent reply other threads:[~2008-09-11 22:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-11 12:03 [PATCH 3/3]: tg3: Use SKB DMA helper functions for TX David Miller
2008-09-11 17:58 ` Michael Chan
2008-09-11 22:45 ` David Miller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080911.154531.136830945.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=mchan@broadcom.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).