From patchwork Sat Mar 25 21:31:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Vernet X-Patchwork-Id: 74984 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp622749vqo; Sat, 25 Mar 2023 14:57:20 -0700 (PDT) X-Google-Smtp-Source: AKy350ak8vYUiyx+Ty1VdgJJLYwNYRNpowrdxTg3Sbm8RHq8QwgHTRQWTsGK211nw4Q/LCJvwFmT X-Received: by 2002:a17:906:5a81:b0:92e:fcc9:aa22 with SMTP id l1-20020a1709065a8100b0092efcc9aa22mr6939380ejq.37.1679781440339; Sat, 25 Mar 2023 14:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679781440; cv=none; d=google.com; s=arc-20160816; b=LRsaI+Hz2aSuZXPgX92XBNienLBKX6vh5c3Fwkf+uafq+nAmIxVN/Fljp1nFDu5u3D rmAOlnN0/olMjPgOVsxFsEvWU4ipUZSjjM/wyn5mlpnKTsCNGeRHyuInSoog8UngW8zK gYKMAOLaUPCW5PIzsJSWd6icjKUOiIbqVOUIQOE9gDb4btpYyC00/9GbhNg6YR78jrpZ ODfXFCVUflsEEaVh1nf7+dpJPbLJ6DEKaroMtke/0Wt2w5A3qF5QuWLMTkmuQT3ZnU7F 0QBUb7e/eJxZpDOM4lOe8BUpoU47D8G5sblKqiDHsLikrxr6O6GGqyiikGZSB4yM2drP JEuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=beTKJfiS4cdFGvjwvhWeZJkcVPSdZmhKDIoBjmdTTxM=; b=l6sAwxKXiUoMFJ9A5pHO2NLlCPPTo2OMpwnavcS1MJtH9qn/1RSoZ8hDq2AerJDjgc tHi4C3BwHfGRyIVVOp37FZupOqQktCUaBQZoiwk1a1omXvM12PR8xl/SZX6gDiHrV2hR AbUCWsgsCq0l5jogldxdsPO02MRloTU6hOwp5lVVfM62ZQGNE/GLD3Z4F4XAJRlJA4QT SxIH7qMG60luF6UEIQ/9WlcqimGyOLHTqY8oxhCFr6/VafEHLdqudW35lvXuLdTfTMMT yi1BLBLJCiggnEOLxh86FNp0pC0z/OOovynT6oVahAptgRqt2w3Sm6eugCSz54Gm14UX vlhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs12-20020a1709073e8c00b0093beaa0092dsi10497867ejc.96.2023.03.25.14.56.48; Sat, 25 Mar 2023 14:57:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230237AbjCYVca (ORCPT + 99 others); Sat, 25 Mar 2023 17:32:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjCYVc3 (ORCPT ); Sat, 25 Mar 2023 17:32:29 -0400 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE2ACCC00; Sat, 25 Mar 2023 14:32:19 -0700 (PDT) Received: by mail-qv1-f53.google.com with SMTP id 59so4293676qva.11; Sat, 25 Mar 2023 14:32:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679779939; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=beTKJfiS4cdFGvjwvhWeZJkcVPSdZmhKDIoBjmdTTxM=; b=wROKc2odk+PGDIC0jrAC4F2WpEt4JtXwUtXOKofljq3jGiNDXJeGB4l/0p3bh5xeyZ hkNz6CuuBn2C4warfq/d5OajSwR65ZF/GVVYMf60qQRLafQ3fBgCk+9I7zi0dHRBw1O0 HW73iNciwpVy2qjVn/zmO12PwVZ1xxwbU3uF3RYYEhLYSszE+oFNmyDZfAcylQbBQ/P/ umUnVJqs+9UgsrLOwTGi5NVyuKIt1T73GGBjmbGORR1SZ+VnhZmc11QKC8yuCyLWukhd A7XYgIkyyDyRhNKEIeUWZBE5PWfVtu3hFjNYY3rRE6Y2vrTl+PTMtorA2P7hH+ZNm+xg 2E9A== X-Gm-Message-State: AAQBX9ew0igcySMQM/n4P/QIFp9fGzM7CiYzlyRcnRMDy4hu0KiZWKoF /0TXVVwDLTeTo9bk6FP0fKdJuUFPS14FNCHeqmo= X-Received: by 2002:a05:6214:2a87:b0:5c6:403d:7af4 with SMTP id jr7-20020a0562142a8700b005c6403d7af4mr10878487qvb.43.1679779938528; Sat, 25 Mar 2023 14:32:18 -0700 (PDT) Received: from localhost ([24.1.27.177]) by smtp.gmail.com with ESMTPSA id mg18-20020a056214561200b005dd8b93457dsm1711403qvb.21.2023.03.25.14.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Mar 2023 14:32:18 -0700 (PDT) From: David Vernet To: bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH bpf-next 2/3] bpf: Remove now-unnecessary NULL checks for KF_RELEASE kfuncs Date: Sat, 25 Mar 2023 16:31:45 -0500 Message-Id: <20230325213144.486885-3-void@manifault.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230325213144.486885-1-void@manifault.com> References: <20230325213144.486885-1-void@manifault.com> MIME-Version: 1.0 X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761378503556307380?= X-GMAIL-MSGID: =?utf-8?q?1761378503556307380?= Now that we're not invoking kfunc destructors when the kptr in a map was NULL, we no longer require NULL checks in many of our KF_RELEASE kfuncs. This patch removes those NULL checks. Signed-off-by: David Vernet --- drivers/hid/bpf/hid_bpf_dispatch.c | 3 --- kernel/bpf/cpumask.c | 3 --- kernel/bpf/helpers.c | 6 ------ net/bpf/test_run.c | 3 --- net/netfilter/nf_conntrack_bpf.c | 2 -- 5 files changed, 17 deletions(-) diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf_dispatch.c index 8a034a555d4c..d9ef45fcaeab 100644 --- a/drivers/hid/bpf/hid_bpf_dispatch.c +++ b/drivers/hid/bpf/hid_bpf_dispatch.c @@ -342,9 +342,6 @@ hid_bpf_release_context(struct hid_bpf_ctx *ctx) { struct hid_bpf_ctx_kern *ctx_kern; - if (!ctx) - return; - ctx_kern = container_of(ctx, struct hid_bpf_ctx_kern, ctx); kfree(ctx_kern); diff --git a/kernel/bpf/cpumask.c b/kernel/bpf/cpumask.c index db9da2194c1a..e991af7dc13c 100644 --- a/kernel/bpf/cpumask.c +++ b/kernel/bpf/cpumask.c @@ -102,9 +102,6 @@ static void cpumask_free_cb(struct rcu_head *head) */ __bpf_kfunc void bpf_cpumask_release(struct bpf_cpumask *cpumask) { - if (!cpumask) - return; - if (refcount_dec_and_test(&cpumask->usage)) call_rcu(&cpumask->rcu, cpumask_free_cb); } diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index f753676ef652..8980f6859443 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -2089,9 +2089,6 @@ __bpf_kfunc struct task_struct *bpf_task_kptr_get(struct task_struct **pp) */ __bpf_kfunc void bpf_task_release(struct task_struct *p) { - if (!p) - return; - put_task_struct(p); } @@ -2148,9 +2145,6 @@ __bpf_kfunc struct cgroup *bpf_cgroup_kptr_get(struct cgroup **cgrpp) */ __bpf_kfunc void bpf_cgroup_release(struct cgroup *cgrp) { - if (!cgrp) - return; - cgroup_put(cgrp); } diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index 8d6b31209bd6..27587f1c5f36 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -615,9 +615,6 @@ bpf_kfunc_call_memb_acquire(void) __bpf_kfunc void bpf_kfunc_call_test_release(struct prog_test_ref_kfunc *p) { - if (!p) - return; - refcount_dec(&p->cnt); } diff --git a/net/netfilter/nf_conntrack_bpf.c b/net/netfilter/nf_conntrack_bpf.c index cd99e6dc1f35..002e9d24a1e9 100644 --- a/net/netfilter/nf_conntrack_bpf.c +++ b/net/netfilter/nf_conntrack_bpf.c @@ -401,8 +401,6 @@ __bpf_kfunc struct nf_conn *bpf_ct_insert_entry(struct nf_conn___init *nfct_i) */ __bpf_kfunc void bpf_ct_release(struct nf_conn *nfct) { - if (!nfct) - return; nf_ct_put(nfct); }