From: Petr Machata <petrm@mellanox.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org,
syzbot+6e95a4fabf88dc217145@syzkaller.appspotmail.com,
Jamal Hadi Salim <jhs@mojatatu.com>,
Jiri Pirko <jiri@resnulli.us>
Subject: Re: [Patch net-next] net_sched: initialize timer earlier in red_init()
Date: Mon, 27 Jul 2020 20:23:29 +0200 [thread overview]
Message-ID: <871rkwizq6.fsf@mellanox.com> (raw)
In-Reply-To: <20200725201707.16909-1-xiyou.wangcong@gmail.com>
Cong Wang <xiyou.wangcong@gmail.com> writes:
> 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: syzbot+6e95a4fabf88dc217145@syzkaller.appspotmail.com
> Fixes: aee9caa03fc3 ("net: sched: sch_red: Add qevents "early_drop" and "mark"")
> Cc: Petr Machata <petrm@mellanox.com>
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Cc: Jiri Pirko <jiri@resnulli.us>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Ah, correct, this used to be done in red_init() not only before calling
red_change(), but actually before doing anything that can fail. Thanks
for fixing this.
Reviewed-by: Petr Machata <petrm@mellanox.com>
> ---
> net/sched/sch_red.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
> index 4cc0ad0b1189..deac82f3ad7b 100644
> --- a/net/sched/sch_red.c
> +++ b/net/sched/sch_red.c
> @@ -333,6 +333,10 @@ static int red_init(struct Qdisc *sch, struct nlattr *opt,
> struct nlattr *tb[TCA_RED_MAX + 1];
> int err;
>
> + q->qdisc = &noop_qdisc;
> + q->sch = sch;
> + timer_setup(&q->adapt_timer, red_adaptative_timer, 0);
> +
> if (!opt)
> return -EINVAL;
>
> @@ -341,10 +345,6 @@ static int red_init(struct Qdisc *sch, struct nlattr *opt,
> if (err < 0)
> return err;
>
> - q->qdisc = &noop_qdisc;
> - q->sch = sch;
> - timer_setup(&q->adapt_timer, red_adaptative_timer, 0);
> -
> err = __red_change(sch, tb, extack);
> if (err)
> return err;
next prev parent reply other threads:[~2020-07-27 18:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-25 20:17 [Patch net-next] net_sched: initialize timer earlier in red_init() Cong Wang
2020-07-27 18:23 ` Petr Machata [this message]
2020-07-29 0:41 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871rkwizq6.fsf@mellanox.com \
--to=petrm@mellanox.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=syzbot+6e95a4fabf88dc217145@syzkaller.appspotmail.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).