Skip to content

Commit

Permalink
bpf: remove redundant null pointer check before consume_skb
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
zhong jiang authored and Daniel Borkmann committed Sep 21, 2018
1 parent 32c0097 commit 788758d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions kernel/bpf/sockmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -973,8 +972,7 @@ static int bpf_tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,

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);
}
}
Expand Down

0 comments on commit 788758d

Please sign in to comment.