Skip to content

Commit

Permalink
sch_htb: fix null pointer dereference on a null new_q
Browse files Browse the repository at this point in the history
sch_htb: fix null pointer dereference on a null new_q

Currently if new_q is null, the null new_q pointer will be
dereference when 'q->offload' is true. Fix this by adding
a braces around htb_parent_to_leaf_offload() to avoid it.

Addresses-Coverity: ("Dereference after null check")
Fixes: d03b195 ("sch_htb: Hierarchical QoS hardware offload")

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Yunjian Wang authored and David S. Miller committed Mar 30, 2021
1 parent 8a03dd9 commit ae81feb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/sched/sch_htb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1675,9 +1675,10 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg,
cl->parent->common.classid,
NULL);
if (q->offload) {
if (new_q)
if (new_q) {
htb_set_lockdep_class_child(new_q);
htb_parent_to_leaf_offload(sch, dev_queue, new_q);
htb_parent_to_leaf_offload(sch, dev_queue, new_q);
}
}
}

Expand Down

0 comments on commit ae81feb

Please sign in to comment.