aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCong Wang <[email protected]>2019-09-12 10:22:30 -0700
committerDavid S. Miller <[email protected]>2019-09-15 20:54:14 +0200
commit6efb971ba8edfbd80b666f29de12882852f095ae (patch)
tree81a0a8101c77ce22309bfd7e6a59b730e1bf47d6
parent23426a25e55a417dc104df08781b6eff95e65f3f (diff)
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 6529eaba33f0.) Fixes: 6529eaba33f0 ("net: sched: introduce tcf block infractructure") Reported-by: [email protected] Suggested-by: Linus Torvalds <[email protected]> Cc: Jamal Hadi Salim <[email protected]> Cc: Jiri Pirko <[email protected]> Signed-off-by: Cong Wang <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
-rw-r--r--net/sched/sch_generic.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index ac28f6a5d70e..17bd8f539bc7 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -985,6 +985,9 @@ static void qdisc_destroy(struct Qdisc *qdisc)
void qdisc_put(struct Qdisc *qdisc)
{
+ if (!qdisc)
+ return;
+
if (qdisc->flags & TCQ_F_BUILTIN ||
!refcount_dec_and_test(&qdisc->refcnt))
return;