Skip to content

Commit 6efb971

Browse files
congwangdavem330
authored andcommitted
net_sched: let qdisc_put() accept NULL pointer
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>
1 parent 23426a2 commit 6efb971

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/sched/sch_generic.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,9 @@ static void qdisc_destroy(struct Qdisc *qdisc)
985985

986986
void qdisc_put(struct Qdisc *qdisc)
987987
{
988+
if (!qdisc)
989+
return;
990+
988991
if (qdisc->flags & TCQ_F_BUILTIN ||
989992
!refcount_dec_and_test(&qdisc->refcnt))
990993
return;

0 commit comments

Comments
 (0)