On Thu, Jan 12, 2017 at 10:21:02AM -0500, David Miller wrote:
> From: Simon Horman <horms+rene...@verge.net.au>
> Date: Thu, 12 Jan 2017 14:53:37 +0100
> 
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 92d7692c840d..3b4d2504285e 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -1508,6 +1508,8 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff 
> > *skb, struct net_device *ndev)
> >     buffer = PTR_ALIGN(priv->tx_align[q], DPTR_ALIGN) +
> >              entry / NUM_TX_DESC * DPTR_ALIGN;
> >     len = PTR_ALIGN(skb->data, DPTR_ALIGN) - skb->data;
> > +   if (len == 0)
> > +           len = skb->len > 4 ? 4 : skb->len;
> >     memcpy(buffer, skb->data, len);
> >     dma_addr = dma_map_single(ndev->dev.parent, buffer, len, DMA_TO_DEVICE);
> >     if (dma_mapping_error(ndev->dev.parent, dma_addr))
> 
> Assume len ends up being skb->len, then the second DMA mapping will be
> made of zero length.
> 
> This code needs a bit of TLC.

Thanks, I realised that after sending this patch.

What I now see is that a few lines further up there is:

         if (skb_put_padto(skb, ETH_ZLEN))
                goto drop;

        where ETH_ZLEN is 60.

So I don't think we need to worry about skb->len being less than 60 and
this patch can be simplified to:

        if (len == 0)
                len = 4;

Reply via email to