cxgb3: Correct comparisons and calculations using skb->tail and skb-transport_header
authorSimon Horman <horms@verge.net.au>
Tue, 28 May 2013 20:34:24 +0000 (20:34 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 29 May 2013 06:49:07 +0000 (23:49 -0700)
This corrects an regression introduced by "net: Use 16bits for *_headers
fields of struct skbuff" when NET_SKBUFF_DATA_USES_OFFSET is not set. In
that case skb->tail will be a pointer whereas skb->transport_header
will be an offset from head. This is corrected by using wrappers that
ensure that comparisons and calculations are always made using pointers.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/chelsio/cxgb3/sge.c

index 2fd773e267dc7d0e328c7baf4b26ca06a2632ba2..46d1efc1752799b81b3bef08b8ac0764f89f5a41 100644 (file)
@@ -1584,9 +1584,8 @@ static void deferred_unmap_destructor(struct sk_buff *skb)
        p = dui->addr;
 
        if (skb->tail - skb->transport_header)
-               pci_unmap_single(dui->pdev, *p++,
-                                skb->tail - skb->transport_header,
-                                PCI_DMA_TODEVICE);
+               pci_unmap_single(dui->pdev, *p++, skb_tail_pointer(skb) -
+                                skb_transport_header(skb), PCI_DMA_TODEVICE);
 
        si = skb_shinfo(skb);
        for (i = 0; i < si->nr_frags; i++)
@@ -1647,8 +1646,8 @@ static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb,
        flits = skb_transport_offset(skb) / 8;
        sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl;
        sgl_flits = write_sgl(skb, sgp, skb_transport_header(skb),
-                            skb->tail - skb->transport_header,
-                            addr);
+                            skb_tail_pointer(skb) -
+                            skb_transport_header(skb), addr);
        if (need_skb_unmap()) {
                setup_deferred_unmapping(skb, adap->pdev, sgp, sgl_flits);
                skb->destructor = deferred_unmap_destructor;
@@ -1674,7 +1673,7 @@ static inline unsigned int calc_tx_descs_ofld(const struct sk_buff *skb)
 
        flits = skb_transport_offset(skb) / 8;  /* headers */
        cnt = skb_shinfo(skb)->nr_frags;
-       if (skb->tail != skb->transport_header)
+       if (skb_tail_pointer(skb) != skb_transport_header(skb))
                cnt++;
        return flits_to_desc(flits + sgl_len(cnt));
 }