From nobody Mon Apr 6 21:56:36 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D591C6FA83 for ; Fri, 2 Sep 2022 08:32:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235710AbiIBIcW (ORCPT ); Fri, 2 Sep 2022 04:32:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235468AbiIBIcN (ORCPT ); Fri, 2 Sep 2022 04:32:13 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1551C0E6B; Fri, 2 Sep 2022 01:32:12 -0700 (PDT) Received: from dggpeml500026.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MJrf52QKKz1N7mK; Fri, 2 Sep 2022 16:28:29 +0800 (CST) Received: from huawei.com (10.175.101.6) by dggpeml500026.china.huawei.com (7.185.36.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 2 Sep 2022 16:32:10 +0800 From: Zhengchao Shao To: , , , , , , , , CC: , , Subject: [PATCH net-next,v2 1/2] net: sched: fq_codel: remove redundant resource cleanup in fq_codel_init() Date: Fri, 2 Sep 2022 16:34:29 +0800 Message-ID: <20220902083430.24378-2-shaozhengchao@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220902083430.24378-1-shaozhengchao@huawei.com> References: <20220902083430.24378-1-shaozhengchao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500026.china.huawei.com (7.185.36.106) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If fq_codel_init() fails, qdisc_create() invokes fq_codel_destroy() to clear resources. Therefore, remove redundant resource cleanup in fq_codel_init(). Signed-off-by: Zhengchao Shao --- v1: rebase --- net/sched/sch_fq_codel.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c index 23a042adb74d..f97b2adb0a44 100644 --- a/net/sched/sch_fq_codel.c +++ b/net/sched/sch_fq_codel.c @@ -481,26 +481,24 @@ static int fq_codel_init(struct Qdisc *sch, struct nl= attr *opt, if (opt) { err =3D fq_codel_change(sch, opt, extack); if (err) - goto init_failure; + return err; } =20 err =3D tcf_block_get(&q->block, &q->filter_list, sch, extack); if (err) - goto init_failure; + return err; =20 if (!q->flows) { q->flows =3D kvcalloc(q->flows_cnt, sizeof(struct fq_codel_flow), GFP_KERNEL); - if (!q->flows) { - err =3D -ENOMEM; - goto init_failure; - } + if (!q->flows) + return -ENOMEM; + q->backlogs =3D kvcalloc(q->flows_cnt, sizeof(u32), GFP_KERNEL); - if (!q->backlogs) { - err =3D -ENOMEM; - goto alloc_failure; - } + if (!q->backlogs) + return -ENOMEM; + for (i =3D 0; i < q->flows_cnt; i++) { struct fq_codel_flow *flow =3D q->flows + i; =20 @@ -513,13 +511,6 @@ static int fq_codel_init(struct Qdisc *sch, struct nla= ttr *opt, else sch->flags &=3D ~TCQ_F_CAN_BYPASS; return 0; - -alloc_failure: - kvfree(q->flows); - q->flows =3D NULL; -init_failure: - q->flows_cnt =3D 0; - return err; } =20 static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb) --=20 2.17.1