cxgb3: Correct comparisons and calculations using skb->tail and skb-transport_header
authorLi RongQing <roy.qing.li@gmail.com>
Mon, 3 Jun 2013 22:11:16 +0000 (22:11 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 5 Jun 2013 00:37:59 +0000 (17:37 -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.

Cc: Simon Horman <horms@verge.net.au>
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/chelsio/cxgb3/sge.c
drivers/net/ethernet/chelsio/cxgb4/sge.c

index 46d1efc1752799b81b3bef08b8ac0764f89f5a41..687ec4a8bb48de001cfa9d39ef233ee7c69a5d96 100644 (file)
@@ -1583,7 +1583,7 @@ static void deferred_unmap_destructor(struct sk_buff *skb)
        dui = (struct deferred_unmap_info *)skb->head;
        p = dui->addr;
 
-       if (skb->tail - skb->transport_header)
+       if (skb_tail_pointer(skb) - skb_transport_header(skb))
                pci_unmap_single(dui->pdev, *p++, skb_tail_pointer(skb) -
                                 skb_transport_header(skb), PCI_DMA_TODEVICE);
 
index 2bfbb206b35af7c943f489ab5cbae9ebb44b8d7e..ac311f5f3eb9590d1d9b5fb3bb0a9c3f0fac5ce7 100644 (file)
@@ -1294,7 +1294,7 @@ static inline unsigned int calc_tx_flits_ofld(const struct sk_buff *skb)
 
        flits = skb_transport_offset(skb) / 8U;   /* 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 + sgl_len(cnt);
 }