net: eliminate meaningless memcpy to data in pskb_carve_inside_nonlinear()
authorMiaohe Lin <linmiaohe@huawei.com>
Sat, 15 Aug 2020 08:48:53 +0000 (04:48 -0400)
committerDavid S. Miller <davem@davemloft.net>
Tue, 18 Aug 2020 22:55:24 +0000 (15:55 -0700)
The frags of skb_shared_info of the data is assigned in following loop. It
is meaningless to do a memcpy of frags here.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/skbuff.c

index 5c3b906..2f7dd68 100644 (file)
@@ -5953,8 +5953,7 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off,
        size = SKB_WITH_OVERHEAD(ksize(data));
 
        memcpy((struct skb_shared_info *)(data + size),
-              skb_shinfo(skb), offsetof(struct skb_shared_info,
-                                        frags[skb_shinfo(skb)->nr_frags]));
+              skb_shinfo(skb), offsetof(struct skb_shared_info, frags[0]));
        if (skb_orphan_frags(skb, gfp_mask)) {
                kfree(data);
                return -ENOMEM;