]> git.baikalelectronics.ru Git - kernel.git/commitdiff
sch_htb: fix null pointer dereference on a null new_q
authorYunjian Wang <wangyunjian@huawei.com>
Tue, 30 Mar 2021 14:27:48 +0000 (22:27 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 30 Mar 2021 20:50:03 +0000 (13:50 -0700)
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: d03b195b5aa0 ("sch_htb: Hierarchical QoS hardware offload")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/sch_htb.c

index 62e12cb41a3e1c0b2403552eb05128e4d3ac50b6..081c11d5717c4a7ad2d76a45f1fd45c47100a5bf 100644 (file)
@@ -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);
+                       }
                }
        }