aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolay Aleksandrov <nikolay@cumulusnetworks.com>2017-08-30 05:49:00 -0400
committerDavid S. Miller <davem@davemloft.net>2017-08-30 18:26:11 -0400
commit3bdac362a2f89ed3e148fa6f38c5f5d858f50b1a (patch)
treeb6de819af8c1171bfbd06a17d65290539ba5218c
parent32db864d33c21fd70a217ba53cb7224889354ffb (diff)
sch_hfsc: fix null pointer deref and double free on init failure
Depending on where ->init fails we can get a null pointer deref due to uninitialized hires timer (watchdog) or a double free of the qdisc hash because it is already freed by ->destroy(). Fixes: 8d5537387505 ("net/sched/hfsc: allocate tcf block for hfsc root class") Fixes: 87b60cfacf9f ("net_sched: fix error recovery at qdisc creation") Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/sched/sch_hfsc.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index fd15200f8627..11ab8dace901 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -1418,6 +1418,8 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt)
1418 struct tc_hfsc_qopt *qopt; 1418 struct tc_hfsc_qopt *qopt;
1419 int err; 1419 int err;
1420 1420
1421 qdisc_watchdog_init(&q->watchdog, sch);
1422
1421 if (opt == NULL || nla_len(opt) < sizeof(*qopt)) 1423 if (opt == NULL || nla_len(opt) < sizeof(*qopt))
1422 return -EINVAL; 1424 return -EINVAL;
1423 qopt = nla_data(opt); 1425 qopt = nla_data(opt);
@@ -1430,7 +1432,7 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt)
1430 1432
1431 err = tcf_block_get(&q->root.block, &q->root.filter_list); 1433 err = tcf_block_get(&q->root.block, &q->root.filter_list);
1432 if (err) 1434 if (err)
1433 goto err_tcf; 1435 return err;
1434 1436
1435 q->root.cl_common.classid = sch->handle; 1437 q->root.cl_common.classid = sch->handle;
1436 q->root.refcnt = 1; 1438 q->root.refcnt = 1;
@@ -1448,13 +1450,7 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt)
1448 qdisc_class_hash_insert(&q->clhash, &q->root.cl_common); 1450 qdisc_class_hash_insert(&q->clhash, &q->root.cl_common);
1449 qdisc_class_hash_grow(sch, &q->clhash); 1451 qdisc_class_hash_grow(sch, &q->clhash);
1450 1452
1451 qdisc_watchdog_init(&q->watchdog, sch);
1452
1453 return 0; 1453 return 0;
1454
1455err_tcf:
1456 qdisc_class_hash_destroy(&q->clhash);
1457 return err;
1458} 1454}
1459 1455
1460static int 1456static int