mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: Soren Brinkmann <soren.brinkmann@xilinx.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Vinod Koul <vinod.koul@intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	"David S. Miller" <davem@davemloft.net>,
	Michal Simek <michal.simek@xilinx.com>
Subject: Re: [PATCH v2 1/2] net: macb: Check DMA mappings for error
Date: Thu, 27 Feb 2014 23:57:39 +0000	[thread overview]
Message-ID: <1393545459.14067.79.camel@deadeye.wl.decadent.org.uk> (raw)
In-Reply-To: <1393538285-28297-1-git-send-email-soren.brinkmann@xilinx.com>

[-- Attachment #1: Type: text/plain, Size: 1859 bytes --]

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.

Ben.

>  	tx_skb = &bp->tx_skb[entry];
>  	tx_skb->skb = skb;
> @@ -1066,6 +1075,7 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  	if (CIRC_SPACE(bp->tx_head, bp->tx_tail, TX_RING_SIZE) < 1)
>  		netif_stop_queue(dev);
>  
> +unlock:
>  	spin_unlock_irqrestore(&bp->lock, flags);
>  
>  	return NETDEV_TX_OK;

-- 
Ben Hutchings
It is easier to change the specification to fit the program than vice versa.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

  parent reply	other threads:[~2014-02-27 23:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-27 21:58 Soren Brinkmann
2014-02-27 21:58 ` [PATCH v2 2/2] net: macb: DMA-unmap full rx-buffer Soren Brinkmann
2014-02-27 23:57 ` Ben Hutchings [this message]
2014-03-01  0:24   ` [PATCH v2 1/2] net: macb: Check DMA mappings for error Sören Brinkmann

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=1393545459.14067.79.camel@deadeye.wl.decadent.org.uk \
    --to=ben@decadent.org.uk \
    --cc=dan.j.williams@intel.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    --cc=soren.brinkmann@xilinx.com \
    --cc=vinod.koul@intel.com \
    /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

all inboxes | Powered by JetHome®