Skip to content

Commit 608b4ad

Browse files
congwangdavem330
authored andcommitted
net_sched: initialize timer earlier in red_init()
When red_init() fails, red_destroy() is called to clean up. If the timer is not initialized yet, del_timer_sync() will complain. So we have to move timer_setup() before any failure. Reported-and-tested-by: [email protected] Fixes: aee9caa ("net: sched: sch_red: Add qevents "early_drop" and "mark"") Cc: Petr Machata <[email protected]> Cc: Jamal Hadi Salim <[email protected]> Cc: Jiri Pirko <[email protected]> Signed-off-by: Cong Wang <[email protected]> Reviewed-by: Petr Machata <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1255457 commit 608b4ad

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/sched/sch_red.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ static int red_init(struct Qdisc *sch, struct nlattr *opt,
333333
struct nlattr *tb[TCA_RED_MAX + 1];
334334
int err;
335335

336+
q->qdisc = &noop_qdisc;
337+
q->sch = sch;
338+
timer_setup(&q->adapt_timer, red_adaptative_timer, 0);
339+
336340
if (!opt)
337341
return -EINVAL;
338342

@@ -341,10 +345,6 @@ static int red_init(struct Qdisc *sch, struct nlattr *opt,
341345
if (err < 0)
342346
return err;
343347

344-
q->qdisc = &noop_qdisc;
345-
q->sch = sch;
346-
timer_setup(&q->adapt_timer, red_adaptative_timer, 0);
347-
348348
err = __red_change(sch, tb, extack);
349349
if (err)
350350
return err;

0 commit comments

Comments
 (0)