Skip to content

Commit cfdaeba

Browse files
Yunsheng Lindavem330
authored andcommitted
net: hns3: fix desc filling bug when skb is expanded or lineared
The linear and frag data part may be changed when the skb is expanded or lineared in skb_cow_head() or skb_checksum_help(), which is called by hns3_fill_skb_desc(), so the linear len return by skb_headlen() before the calling of hns3_fill_skb_desc() is unreliable. Move hns3_fill_skb_desc() before the calling of skb_headlen() to fix this bug. Fixes: 76ad4f0 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") Signed-off-by: Yunsheng Lin <[email protected]> Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 181964e commit cfdaeba

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,16 +1093,8 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
10931093
int k, sizeoflast;
10941094
dma_addr_t dma;
10951095

1096-
if (type == DESC_TYPE_SKB) {
1097-
struct sk_buff *skb = (struct sk_buff *)priv;
1098-
int ret;
1099-
1100-
ret = hns3_fill_skb_desc(ring, skb, desc);
1101-
if (unlikely(ret < 0))
1102-
return ret;
1103-
1104-
dma = dma_map_single(dev, skb->data, size, DMA_TO_DEVICE);
1105-
} else if (type == DESC_TYPE_FRAGLIST_SKB) {
1096+
if (type == DESC_TYPE_FRAGLIST_SKB ||
1097+
type == DESC_TYPE_SKB) {
11061098
struct sk_buff *skb = (struct sk_buff *)priv;
11071099

11081100
dma = dma_map_single(dev, skb->data, size, DMA_TO_DEVICE);
@@ -1439,6 +1431,10 @@ netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
14391431

14401432
next_to_use_head = ring->next_to_use;
14411433

1434+
ret = hns3_fill_skb_desc(ring, skb, &ring->desc[ring->next_to_use]);
1435+
if (unlikely(ret < 0))
1436+
goto fill_err;
1437+
14421438
ret = hns3_fill_skb_to_desc(ring, skb, DESC_TYPE_SKB);
14431439
if (unlikely(ret < 0))
14441440
goto fill_err;

0 commit comments

Comments
 (0)