Received: by 10.223.185.116 with SMTP id b49csp338622wrg; Thu, 22 Feb 2018 22:59:48 -0800 (PST) X-Google-Smtp-Source: AH8x2271ixezwauL86WDuSEZEt9Px9gLDXOYiQYwhqB6Go9E80ryhgzJVzaWtzXUpkg0a2P8JymB X-Received: by 10.101.96.212 with SMTP id r20mr640918pgv.139.1519369188748; Thu, 22 Feb 2018 22:59:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519369188; cv=none; d=google.com; s=arc-20160816; b=ZGoVavIMvmmc3GZcHcBHaZCD6AUSKnVyiY3VSj9GtSYp/X3qHSg+8qyqp6JqtFvKrb 31hdWC5igmW0ts7/QBcKbsfPR0mi5prlwEBWPjyDq9po1jz0W5A1ZsEnxm3m5y6W6zuf hPBccZTo686zaFlvSz/3LbUFFCYcZ2DPBrdqioBryho3SEaBtdfc0Xts6MTrOCIju4C/ suWhAxVOO6cBJ2j0htMKoBXVuTLCdwiZszPBhn2j8qUZwGjRIC7gP2iTo5Myk7SNiclE 406lpHKA5KWleP+rOoepXMcAYod5kWULIo62e8p1RYXuBQFLVuO6QqAhUQkyMavfhrON /6FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=kb+hMjVdmY7JjmhwKjsaGILdzBEQyGd2PgvtMe03XCc=; b=uQxXLyZdd3drfjmMqROtl6fH3gXA2USy6eytggfevS5W8P7fDhHjwSJ2vni7SIf9px SnM+yxFR19CNm7V0npPUzPnZITs0xb0i9n5YXqF1NHzJc+9YD7XFx1/6q3JzNokIJ/MX HqhDDzYCZXQ4JdTfaaPhAg01fBxH7dNQQurqpI9kgCO3v+w/70+nsV5xIeu8QXWNYIEw +T9IR5+UnE58fG78PWprZLtnEYC1D4V163jBMXfpc6J7BPCeeOAyv36+1RzHNvWHj0DH teFGnwpEJQCzOKNrLB7OPkQhEDDOz2E+7uRYUB+6RZAFgyi1AJl/wtaIuZdqBpSeSy9i WYAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=d2usc9UL; 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 o6-v6si1334630plk.820.2018.02.22.22.59.34; Thu, 22 Feb 2018 22:59:48 -0800 (PST) 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=d2usc9UL; 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 S1751494AbeBWG64 (ORCPT + 99 others); Fri, 23 Feb 2018 01:58:56 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:44210 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751411AbeBWG6y (ORCPT ); Fri, 23 Feb 2018 01:58:54 -0500 Received: by mail-pl0-f67.google.com with SMTP id w21so4417967plp.11; Thu, 22 Feb 2018 22:58:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=kb+hMjVdmY7JjmhwKjsaGILdzBEQyGd2PgvtMe03XCc=; b=d2usc9ULIDUIa943YtLr0Y8e7bK2+8PDlZT2P0EzOxYGVM/AugQKZU+pTaRsGrLih1 QrL8tg+5DbpFAkbDiiLM8IaxOTG2I9A0NR3EsKFjk5X9EMfojDFOdoh5EIkzURjNacv5 PR2PYG+B8LiDSFe+78PCldmHfT48BlkSAVKTb96FhjIn3kyk+uCPoHjmj8KGaLsnQoW2 Z67Nmbh4ICt4nWWscicdShacReFXhlXqekyf1lEY05YEU4V3pPWS+UY4KCJWkH3aC0Zp MPX28xi/KZ5Q2r8ItCvRBxLjR6cniGLKallLefCSYDVVtKdYd/kFCP/ePRLj89bY1aug DfIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=kb+hMjVdmY7JjmhwKjsaGILdzBEQyGd2PgvtMe03XCc=; b=AUd+GTiVXv1xnzAbTJi21n4tlYWCmkrrk0UPzpAyHx7GCzhORT4ArfL514XuB7gs0k 4D/2kEwLw0KvuJicaQpJ0plHv0Qs4YmDucI7cuOVtWO99AyXEt7F0nE5Kb/8eQ59oE6k LouAp/GvpQ3uxzejrS/DnhZQj41jMf5xoemHNL/XBikXVVlH2KVF8Pn0D32ya395+nPq N0+WYLF0UTXZa5zfTzLeGWrPfkXwAKeHN+8oqxZX5rRlT64b/TSsTEboBCCUh3QuKLKf IfMblGVwltE+wXyd9iWxlMgpHD3bf72bbfEhdATLZf6W/+y7I2l9qrJZnUZpQyCBPaZl hE6Q== X-Gm-Message-State: APf1xPDO7h2nUqiDYY3javZwpG9FTX/CsXNbJ4MByALk3k+3bA0Q1pk4 Y+tHLIiAlAXL9W/ypqlX+io= X-Received: by 2002:a17:902:a517:: with SMTP id s23-v6mr772322plq.1.1519369134289; Thu, 22 Feb 2018 22:58:54 -0800 (PST) Received: from li1588-6.members.linode.com (li1588-6.members.linode.com. [139.162.104.6]) by smtp.gmail.com with ESMTPSA id 76sm3611455pfp.53.2018.02.22.22.58.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Feb 2018 22:58:52 -0800 (PST) From: Yafang Shao To: dsa@cumulusnetworks.com, ast@kernel.org, daniel@iogearbox.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH bpf-next] bpf: NULL pointer check is not needed in BPF_CGROUP_RUN_PROG_INET_SOCK Date: Fri, 23 Feb 2018 14:58:41 +0800 Message-Id: <1519369121-22269-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sk is already allocated in inet_create/inet6_create, hence when BPF_CGROUP_RUN_PROG_INET_SOCK is executed sk will never be NULL. The logic is as bellow, sk = sk_alloc(); if (!sk) goto out; BPF_CGROUP_RUN_PROG_INET_SOCK(sk); Signed-off-by: Yafang Shao --- include/linux/bpf-cgroup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h index a7f16e0..8a45666 100644 --- a/include/linux/bpf-cgroup.h +++ b/include/linux/bpf-cgroup.h @@ -96,7 +96,7 @@ int __cgroup_bpf_check_dev_permission(short dev_type, u32 major, u32 minor, #define BPF_CGROUP_RUN_PROG_INET_SOCK(sk) \ ({ \ int __ret = 0; \ - if (cgroup_bpf_enabled && sk) { \ + if (cgroup_bpf_enabled) { \ __ret = __cgroup_bpf_run_filter_sk(sk, \ BPF_CGROUP_INET_SOCK_CREATE); \ } \ -- 1.8.3.1