浏览代码

bpf: remove redundant null pointer check before consume_skb

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>
zhong jiang 7 年之前
父节点
当前提交
788758d1fe
共有 1 个文件被更改,包括 2 次插入4 次删除
  1. 2 4
      kernel/bpf/sockmap.c

+ 2 - 4
kernel/bpf/sockmap.c

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