net: sched: fq_codel: remove redundant resource cleanup in fq_codel_init()
authorZhengchao Shao <shaozhengchao@huawei.com>
Fri, 2 Sep 2022 08:34:29 +0000 (16:34 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 3 Sep 2022 09:40:40 +0000 (10:40 +0100)
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 <shaozhengchao@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/sch_fq_codel.c

index f16f471daa8105d9705ffbcc166832824cdff9ac..eeea8c6d54e29c6dd34a37a7452b6fc58893ea0b 100644 (file)
@@ -478,26 +478,24 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt,
        if (opt) {
                err = fq_codel_change(sch, opt, extack);
                if (err)
-                       goto init_failure;
+                       return err;
        }
 
        err = tcf_block_get(&q->block, &q->filter_list, sch, extack);
        if (err)
-               goto init_failure;
+               return err;
 
        if (!q->flows) {
                q->flows = kvcalloc(q->flows_cnt,
                                    sizeof(struct fq_codel_flow),
                                    GFP_KERNEL);
-               if (!q->flows) {
-                       err = -ENOMEM;
-                       goto init_failure;
-               }
+               if (!q->flows)
+                       return -ENOMEM;
+
                q->backlogs = kvcalloc(q->flows_cnt, sizeof(u32), GFP_KERNEL);
-               if (!q->backlogs) {
-                       err = -ENOMEM;
-                       goto alloc_failure;
-               }
+               if (!q->backlogs)
+                       return -ENOMEM;
+
                for (i = 0; i < q->flows_cnt; i++) {
                        struct fq_codel_flow *flow = q->flows + i;
 
@@ -510,13 +508,6 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt,
        else
                sch->flags &= ~TCQ_F_CAN_BYPASS;
        return 0;
-
-alloc_failure:
-       kvfree(q->flows);
-       q->flows = NULL;
-init_failure:
-       q->flows_cnt = 0;
-       return err;
 }
 
 static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb)