bpf: remove redundant null pointer check before consume_skb
authorzhong jiang <zhongjiang@huawei.com>
Thu, 20 Sep 2018 09:46:12 +0000 (17:46 +0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 21 Sep 2018 20:51:51 +0000 (22:51 +0200)
consume_skb has taken the null pointer into account. hence it is safe
to remove the redundant null pointer check before consume_skb.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/sockmap.c

index 488ef96..a9359cb 100644 (file)
@@ -590,8 +590,7 @@ static int free_sg(struct sock *sk, int start,
                if (i == MAX_SKB_FRAGS)
                        i = 0;
        }
-       if (md->skb)
-               consume_skb(md->skb);
+       consume_skb(md->skb);
 
        return free;
 }
@@ -973,8 +972,7 @@ bytes_ready:
 
                if (!sg->length && md->sg_start == md->sg_end) {
                        list_del(&md->list);
-                       if (md->skb)
-                               consume_skb(md->skb);
+                       consume_skb(md->skb);
                        kfree(md);
                }
        }