Skip to content

Commit

Permalink
net_sched: fix error path in red_init()
Browse files Browse the repository at this point in the history
When ->init() fails, ->destroy() is called to clean up.
So it is unnecessary to clean up in red_init(), and it
would cause some refcount underflow.

Fixes: aee9caa ("net: sched: sch_red: Add qevents "early_drop" and "mark"")
Reported-and-tested-by: [email protected]
Reported-and-tested-by: [email protected]
Cc: Petr Machata <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Reviewed-by: Petr Machata <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
congwang authored and davem330 committed Aug 28, 2020
1 parent f272285 commit 5438dd4
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions net/sched/sch_red.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,23 +353,11 @@ static int red_init(struct Qdisc *sch, struct nlattr *opt,
FLOW_BLOCK_BINDER_TYPE_RED_EARLY_DROP,
tb[TCA_RED_EARLY_DROP_BLOCK], extack);
if (err)
goto err_early_drop_init;

err = tcf_qevent_init(&q->qe_mark, sch,
FLOW_BLOCK_BINDER_TYPE_RED_MARK,
tb[TCA_RED_MARK_BLOCK], extack);
if (err)
goto err_mark_init;

return 0;
return err;

err_mark_init:
tcf_qevent_destroy(&q->qe_early_drop, sch);
err_early_drop_init:
del_timer_sync(&q->adapt_timer);
red_offload(sch, false);
qdisc_put(q->qdisc);
return err;
return tcf_qevent_init(&q->qe_mark, sch,
FLOW_BLOCK_BINDER_TYPE_RED_MARK,
tb[TCA_RED_MARK_BLOCK], extack);
}

static int red_change(struct Qdisc *sch, struct nlattr *opt,
Expand Down

0 comments on commit 5438dd4

Please sign in to comment.