Skip to content

Commit

Permalink
net_sched: let qdisc_put() accept NULL pointer
Browse files Browse the repository at this point in the history
[ Upstream commit 6efb971 ]

When tcf_block_get() fails in sfb_init(), q->qdisc is still a NULL
pointer which leads to a crash in sfb_destroy(). Similar for
sch_dsmark.

Instead of fixing each separately, Linus suggested to just accept
NULL pointer in qdisc_put(), which would make callers easier.

(For sch_dsmark, the bug probably exists long before commit
6529eab.)

Fixes: 6529eab ("net: sched: introduce tcf block infractructure")
Reported-by: syzbot+d5870a903591faaca4ae@syzkaller.appspotmail.com
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Cong Wang authored and Greg Kroah-Hartman committed Sep 21, 2019
1 parent 9c9b259 commit 5d048c3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/sched/sch_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,11 @@ static void qdisc_rcu_free(struct rcu_head *head)

void qdisc_destroy(struct Qdisc *qdisc)
{
const struct Qdisc_ops *ops = qdisc->ops;
const struct Qdisc_ops *ops;

if (!qdisc)
return;
ops = qdisc->ops;

if (qdisc->flags & TCQ_F_BUILTIN ||
!atomic_dec_and_test(&qdisc->refcnt))
Expand Down

0 comments on commit 5d048c3

Please sign in to comment.