Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2305169imm; Thu, 20 Sep 2018 10:54:34 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZGSzzkRDfYas6LANxFnOSUC0MVlOttjZyBil7imBJCQlaizGc+fKEvDDkBoh1v+Ot8CONt X-Received: by 2002:a17:902:4503:: with SMTP id m3-v6mr40158030pld.168.1537466074460; Thu, 20 Sep 2018 10:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537466074; cv=none; d=google.com; s=arc-20160816; b=Edc5EUGoS3HSDzeSABUy1i02KyAR5qGvqk1iYlVo4eMJgLblERyDMNW2h8MjH0pW2R PFwGsIGB+UFUSI//jodSKF8AA2lV3JJ0ip7Z/VGaPsb584DxS8WArSe4ayMdnr9kskm1 XTVLqXzK8zQAdjL0jA3jSSMlmlfW/ah6RZ4UeaxmN5coVmIUeBYMAtgM+zgdaGjBITKr IUivTf+cxYOoIxUS3BVDsAydNFGbfHbFOpGASsMOcxVWTkBAR3AeBlWdpzsaJlliYXWb FFy2/gMXVtKSYW71g6T+oD2K/bfJ+Zwhf7z+0weqvprqy0+Q6HnmBQ25Kh/sRMbHzmT3 PSeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=J+IM8Bs4Hxgv/xaq0Rp/Kg5fdqMLjnzZsBNu/3Agie8=; b=JhfV3xLZXrrTHZrLIanyGEjl4b8fj+biwwQWqJqZ1XEmy+T+meKiWWr7V3+xjUmsdz qqi9dq1Oooy5cwJGwA5Jndm67DY6tymJWoq5LcxjxP3MCRA1tkb34P9v64NV4EFKYz8h O/c8UDe2VcOzvhA7GSc35HDlTnopHC1Xsd/AWFbKT8dQ6ClkkKTprFgQxAHTBHjS7qiG lKzkKc1XED07t32pcQjJCBafP61Gxxp4mMNF1alhw9UtHLMUk9erRSa3IylBUVl0WD/C KCVPxyPzq4aUWXJPxQVU76VmDxfWTfh2gQuFjKJpz6EJ50lsldo5mAaUAm56+vNgG3nb mPLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nGl49qWv; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 22-v6si25419141pfl.220.2018.09.20.10.54.18; Thu, 20 Sep 2018 10:54:34 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nGl49qWv; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732477AbeITXit (ORCPT + 99 others); Thu, 20 Sep 2018 19:38:49 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:33842 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726582AbeITXit (ORCPT ); Thu, 20 Sep 2018 19:38:49 -0400 Received: by mail-qk1-f193.google.com with SMTP id p84-v6so5594184qke.1; Thu, 20 Sep 2018 10:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=J+IM8Bs4Hxgv/xaq0Rp/Kg5fdqMLjnzZsBNu/3Agie8=; b=nGl49qWvXIHN2eZgHMYvErx9kwvnOyAIaIlj2FWZ1MCZ9VApM6UQ5pZPlvvb13rD+c xS8L3QVD5OvuXkK1M0GHuC23iOxZte9NUVM+Xrys4dbnG7H38SYbHiNT2w9+OacdQGJW a02/Cc3kA4RrYDo8WhTakBbmFpW+Nn2RY6iF8feboIGcMAmpwvvaQU1Zl2+GWjreitkK wcrxgWnj8j20ZYVwRtAJwAvLQRpmgAILMf3erkCU8/7HUTdczrUTminxml/U5jRbIaC7 89O/+LZ9gHmGBVPbOUd7x7w3ONWiv78TOExVduldrLJdlP8TJIXDEblov34Uo3n1YAlg +asg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=J+IM8Bs4Hxgv/xaq0Rp/Kg5fdqMLjnzZsBNu/3Agie8=; b=hRzsG4EAp871j/61AnoeE9lq1mjGK3WQNqjNLoTwDijxouJfQINPtJWSP2dtsF8QCn hYUXo3DlPVfZNw7xbWkZUEV8XNG/PR5USvlmgQOYBw42q72KYlkn9mqUskIXjUwn18oy 8rlynjoOGG3lffGdjX2wJY6K9/IGvbQTxgknrgwXqIUSYC4lNsmACnyUQA17DHOjAA6N 6znHSLRbORBbqBvjysyePrwc+9gIhNNrYPiA56jyyXmIdcFwiPD5c89nBEeojTHDkJZQ AdHMj9PxwwBxRUUW+CAIQHrGiUMHevPbM8Ynb9VRc36+i+PiFgTMrXM00Du59/qtBMVx Ik/w== X-Gm-Message-State: APzg51AwsCxvwovTRUWp2IESDytRE08JIt9njtph/WrFVmZJSxRz6RW8 xQIDGABS4XdhxtqcUy4KotGacr+yqMz+3sbAjmg= X-Received: by 2002:a37:1f9a:: with SMTP id n26-v6mr8842837qkh.120.1537466050732; Thu, 20 Sep 2018 10:54:10 -0700 (PDT) MIME-Version: 1.0 References: <1537436772-42545-1-git-send-email-zhongjiang@huawei.com> In-Reply-To: <1537436772-42545-1-git-send-email-zhongjiang@huawei.com> From: Song Liu Date: Thu, 20 Sep 2018 10:53:59 -0700 Message-ID: Subject: Re: [PATCH] bpf: remove redundant null pointer check before consume_skb To: zhongjiang@huawei.com Cc: Alexei Starovoitov , Daniel Borkmann , Networking , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 20, 2018 at 3:00 AM zhong jiang wrote: > > 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 Acked-by: Song Liu > --- > 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 >