net_sched: check noop_qdisc before qdisc_hash_add()

Dmitry reported a crash when injecting faults in
attach_one_default_qdisc() and dev->qdisc is still
a noop_disc, the check before qdisc_hash_add() fails
to catch it because it tests NULL. We should test
against noop_qdisc since it is the default qdisc
at this point.

Fixes: 59cc1f61f0 ("net: sched: convert qdisc linked list to hashtable")
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
WANG Cong 2017-04-04 18:51:30 -07:00 коммит произвёл David S. Miller
Родитель a8801799c6
Коммит 92f9170621
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -794,7 +794,7 @@ static void attach_default_qdiscs(struct net_device *dev)
}
}
#ifdef CONFIG_NET_SCHED
if (dev->qdisc)
if (dev->qdisc != &noop_qdisc)
qdisc_hash_add(dev->qdisc);
#endif
}