Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1791376imm; Thu, 20 Sep 2018 03:01:00 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda0h9ZL1MFjMvw5qnsgy5Lcx9xe9dr/MTtxECYKkeT6r+XHq6AYZfX8hEvGfHa46qXivckK X-Received: by 2002:a62:938e:: with SMTP id r14-v6mr41289326pfk.55.1537437660478; Thu, 20 Sep 2018 03:01:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537437660; cv=none; d=google.com; s=arc-20160816; b=IROhPxcXYUfEQoLVV2C/ooR2Hen9cFmsMwNtpE0tKiwg4ziVCU+CQ93wGjjfaS2KKs ac4PDkMxfb8APieqR44qndG1HkktHlEnhthWMU6ywJDtvIwarnNSPoQ5K8SHmZfRMRJv rxNOa5okxPT5l/DJLxcs0L1OtjaPMdr75LiCPu3xSj9aJto1cTh4p0AUgNiyMH1eTFYh Vkx6ALDm3di+fw1xOZs9h4QveDU0tSKwt4XgWQQVCd+Azs6hG1gc1P/MTU9yYjOCD674 UYQhFiW5Jt08Z6Q40QJ4fjFk6HjgmS930Llk0S4Zs/JG8K++jvzCpJqW27zi3c4za12l +dDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=pk/KdWxxmthMaAZ+fLsF1HzOBMgqfdSal5G/vy0N3Rs=; b=wr4zDO2sKTP+6r5nd5WRtwMT4geEACZcgx1VBlNeNPK5unWE58GNJrFv4cmZFLwC3L kdWyf+sk+IL02Jl9378VUP2Fo0yom0MJ0/yKUFqpgchNs3YJKyK4jl/0wuLTtsGtNcs+ 1WZEvvxPdCHIV4LhXiphMKrACtLoVBxzRQ1SA7ZTx2ygA26cTZSjtG2TRC0Qugei5vpb BuTnb6brGKK5NoJlC/7jpYVIoHny2EfZM+AsrFAcMfVd8QuZvx5/ZGQEyWrzgp5QkXeq kzBraU7ffFVhL/ZRQ4yiMhVJZiP4aMsm9nyifPX8zLlyTYF37ZBuqAOCZ+EPMCMcKygZ CZHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5-v6si23693240ple.241.2018.09.20.03.00.44; Thu, 20 Sep 2018 03:01:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387469AbeITPlR (ORCPT + 99 others); Thu, 20 Sep 2018 11:41:17 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:56766 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732412AbeITPlR (ORCPT ); Thu, 20 Sep 2018 11:41:17 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 4FCF48125E7B9; Thu, 20 Sep 2018 17:58:34 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.399.0; Thu, 20 Sep 2018 17:58:34 +0800 From: zhong jiang To: , CC: , Subject: [PATCH] bpf: remove redundant null pointer check before consume_skb Date: Thu, 20 Sep 2018 17:46:12 +0800 Message-ID: <1537436772-42545-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- kernel/bpf/sockmap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c index 488ef96..a9359cb 100644 --- a/kernel/bpf/sockmap.c +++ b/kernel/bpf/sockmap.c @@ -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 @@ 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); } } -- 1.7.12.4