From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753033AbaCAAYj (ORCPT ); Fri, 28 Feb 2014 19:24:39 -0500 Received: from ch1ehsobe006.messaging.microsoft.com ([216.32.181.186]:25944 "EHLO ch1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752755AbaCAAYf convert rfc822-to-8bit (ORCPT ); Fri, 28 Feb 2014 19:24:35 -0500 X-Forefront-Antispam-Report: CIP:149.199.60.83;KIP:(null);UIP:(null);IPV:NLI;H:xsj-gw1;RD:unknown-60-83.xilinx.com;EFVD:NLI X-SpamScore: -2 X-BigFish: VPS-2(zz98dIc89bh936eI1432Izz1f42h2148h208ch1ee6h1de0h1fdah2149h2073h2146h1202h1e76h2189h1d1ah1d2ah21bch1fc6hzzz2fh95h839h93fhc61hd24hf0ah119dh1288h12a5h12a9h12bdh137ah13b6h1441h14ddh1504h1537h153bh162dh1631h1758h18e1h1946h19b5h1b0ah224fh1d0ch1d2eh1d3fh1dfeh1dffh1e1dh1fe8h1ff5h209eh2216h2336h2438h2461h2487h24d7h2516h2545h255eh906i1155h) Date: Fri, 28 Feb 2014 16:24:20 -0800 From: =?utf-8?B?U8O2cmVu?= Brinkmann To: Ben Hutchings CC: Nicolas Ferre , , , Vinod Koul , Dan Williams , "David S. Miller" , Michal Simek Subject: Re: [PATCH v2 1/2] net: macb: Check DMA mappings for error References: <1393538285-28297-1-git-send-email-soren.brinkmann@xilinx.com> <1393545459.14067.79.camel@deadeye.wl.decadent.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: <1393545459.14067.79.camel@deadeye.wl.decadent.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) X-RCIS-Action: ALLOW Message-ID: Content-Transfer-Encoding: 8BIT X-OriginatorOrg: xilinx.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ben, On Thu, 2014-02-27 at 11:57PM +0000, Ben Hutchings wrote: > On Thu, 2014-02-27 at 13:58 -0800, Soren Brinkmann wrote: > [...] > > diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c > > index 3190d38e16fb..a9c2ccfc1740 100644 > > --- a/drivers/net/ethernet/cadence/macb.c > > +++ b/drivers/net/ethernet/cadence/macb.c > > @@ -632,11 +632,16 @@ static void gem_rx_refill(struct macb *bp) > > "Unable to allocate sk_buff\n"); > > break; > > } > > - bp->rx_skbuff[entry] = skb; > > > > /* now fill corresponding descriptor entry */ > > paddr = dma_map_single(&bp->pdev->dev, skb->data, > > bp->rx_buffer_size, DMA_FROM_DEVICE); > > + if (dma_mapping_error(&bp->pdev->dev, paddr)) { > > + dev_kfree_skb(skb); > > + break; > > + } > > + > > + bp->rx_skbuff[entry] = skb; > > > > if (entry == RX_RING_SIZE - 1) > > paddr |= MACB_BIT(RX_WRAP); > > @@ -1040,6 +1045,10 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) > > A bit more context: > > entry = macb_tx_ring_wrap(bp->tx_head); > bp->tx_head++; > > > netdev_vdbg(bp->dev, "Allocated ring entry %u\n", entry); > > mapping = dma_map_single(&bp->pdev->dev, skb->data, > > len, DMA_TO_DEVICE); > > + if (dma_mapping_error(&bp->pdev->dev, mapping)) { > > + kfree_skb(skb); > > + goto unlock; > > + } > > You need to move the bp->tx_head increment below this error check. > Sorry I didn't spot this the first time. No problem. I'll wait till next week with a re-spin, in case somebody else has comments. Sören