From patchwork Mon Sep 28 18:31:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Wang X-Patchwork-Id: 289465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87FEDC2D0A8 for ; Mon, 28 Sep 2020 18:31:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 32F1C20774 for ; Mon, 28 Sep 2020 18:31:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Chhh76Do" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726666AbgI1SbT (ORCPT ); Mon, 28 Sep 2020 14:31:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726638AbgI1SbS (ORCPT ); Mon, 28 Sep 2020 14:31:18 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF158C061755 for ; Mon, 28 Sep 2020 11:31:18 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id k8so1849218pfk.2 for ; Mon, 28 Sep 2020 11:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=r3igR5FS7GPjO75PJm/VUDjHivrJMWVOtvekiljL88U=; b=Chhh76DobIx9RZAiT5K1eZDwNERB5zo6RXBFgAUQYbDGHPxvleiR5XjMzalDjkyqZS 1aIc5pIyJwoTHfQt8TuNePwDFDg9H5G6gbFEdnbq0EX4SPhwjqQ8LkgZC3asKRdktPho ecQDdIzq/NRVlyCS7cVT2+Tuo7vDqCHvu6CHseiTlLaAFLmgNZaak7mOSXgY85IFEQrg 2FsWWR6O/KDYEnw5Ms2EVSKdwaggt7U2EfKqfo2o4zARuc3UPzTXNgD3JFoVMGNkHGET EthxEESJaSrLZ94n5vuMS2rjgUXT3/LheFJkarE2X+V/SodW+ExOGk0Gv5EEqZpSefOp 7nPg== 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:mime-version :content-transfer-encoding; bh=r3igR5FS7GPjO75PJm/VUDjHivrJMWVOtvekiljL88U=; b=rr8vVHxYJzoSpoGYo3E2jdRgHfF7G7IMfHIajZviYYIpsMZJcyvkBLKfQ7QzRScPOs hzbQdNEJQZBJQ2XxBn4VWmHVNnp/Z8q4BcULlpe8H+AMd7XPia8iEo6wnDMkzNhkPhHX q1bn914L02Klf7s/EJa5eWqdDZrI+VdoUeN0jFpsl8YGnbi/lOIcNRNRvMD/ZAyHiF2a q1gUcM1UHwUdH7aLoHLMYdJH04jL7VX0sPGNp294VtNNalWn4WujmQ3327ryt60AV39F wmthjsrPV435THELJq8gW9Pregsxi/LpFxH9Jsp71TffF+RJGZHDF2ZlvL/rjh7EV4Rn /Nxg== X-Gm-Message-State: AOAM532ofYbgq2xjv0iGnZ8LU7CFnOg58n1zj30u1Py62zTW5qwXzV5N iZi4tavnpw+KjN7RyrvRmOyAwPt/bH191w== X-Google-Smtp-Source: ABdhPJxlZ5E3U72WvNXJ2F4C/DjJV4XlKHpozT5d1np600R17weF1e61bmqOKEl+7ngSzXSCkV38Xg== X-Received: by 2002:aa7:9204:0:b029:14b:f92e:f57 with SMTP id 4-20020aa792040000b029014bf92e0f57mr496003pfo.16.1601317877325; Mon, 28 Sep 2020 11:31:17 -0700 (PDT) Received: from unknown.linux-6brj.site ([2600:1700:65a0:ab60::46]) by smtp.gmail.com with ESMTPSA id s22sm2565934pfd.90.2020.09.28.11.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 11:31:16 -0700 (PDT) From: Cong Wang To: netdev@vger.kernel.org Cc: Cong Wang , Vlad Buslov , Davide Caratti , Jamal Hadi Salim , Jiri Pirko Subject: [Patch net] net_sched: remove a redundant goto chain check Date: Mon, 28 Sep 2020 11:31:03 -0700 Message-Id: <20200928183103.28442-1-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org All TC actions call tcf_action_check_ctrlact() to validate goto chain, so this check in tcf_action_init_1() is actually redundant. Remove it to save troubles of leaking memory. Fixes: e49d8c22f126 ("net_sched: defer tcf_idr_insert() in tcf_action_init_1()") Reported-by: Vlad Buslov Suggested-by: Davide Caratti Cc: Jamal Hadi Salim Cc: Jiri Pirko Signed-off-by: Cong Wang Reviewed-by: Davide Caratti --- net/sched/act_api.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 104b47f5184f..5612b336e18e 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -722,13 +722,6 @@ int tcf_action_destroy(struct tc_action *actions[], int bind) return ret; } -static int tcf_action_destroy_1(struct tc_action *a, int bind) -{ - struct tc_action *actions[] = { a, NULL }; - - return tcf_action_destroy(actions, bind); -} - static int tcf_action_put(struct tc_action *p) { return __tcf_action_put(p, false); @@ -1000,13 +993,6 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, if (err < 0) goto err_mod; - if (TC_ACT_EXT_CMP(a->tcfa_action, TC_ACT_GOTO_CHAIN) && - !rcu_access_pointer(a->goto_chain)) { - tcf_action_destroy_1(a, bind); - NL_SET_ERR_MSG(extack, "can't use goto chain with NULL chain"); - return ERR_PTR(-EINVAL); - } - if (!name && tb[TCA_ACT_COOKIE]) tcf_set_action_cookie(&a->act_cookie, cookie);