diff options
author | Colin Ian King <colin.king@canonical.com> | 2017-10-17 11:01:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-19 08:13:14 -0400 |
commit | 22ce97fe49b5522e0f97b7c2282ed71a1abd7410 (patch) | |
tree | 9117bf5372fd50adbfc458f7542c98ed5c0338d9 | |
parent | fa31f0c98d64212b2b2b4a1e6d887208b6acb2d9 (diff) |
mqprio: fix potential null pointer dereference on opt
The pointer opt has a null check however before for this check opt is
dereferenced when len is initialized, hence we potentially have a null
pointer deference on opt. Avoid this by checking for a null opt before
dereferencing it.
Detected by CoverityScan, CID#1458234 ("Dereference before null check")
Fixes: 4e8b86c06269 ("mqprio: Introduce new hardware offload mode and shaper in mqprio")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/sched/sch_mqprio.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index cae91b4b08a6..51c2b289c69b 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c | |||
@@ -142,7 +142,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt) | |||
142 | struct nlattr *tb[TCA_MQPRIO_MAX + 1]; | 142 | struct nlattr *tb[TCA_MQPRIO_MAX + 1]; |
143 | struct nlattr *attr; | 143 | struct nlattr *attr; |
144 | int rem; | 144 | int rem; |
145 | int len = nla_len(opt) - NLA_ALIGN(sizeof(*qopt)); | 145 | int len; |
146 | 146 | ||
147 | BUILD_BUG_ON(TC_MAX_QUEUE != TC_QOPT_MAX_QUEUE); | 147 | BUILD_BUG_ON(TC_MAX_QUEUE != TC_QOPT_MAX_QUEUE); |
148 | BUILD_BUG_ON(TC_BITMASK != TC_QOPT_BITMASK); | 148 | BUILD_BUG_ON(TC_BITMASK != TC_QOPT_BITMASK); |
@@ -164,6 +164,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt) | |||
164 | if (mqprio_parse_opt(dev, qopt)) | 164 | if (mqprio_parse_opt(dev, qopt)) |
165 | return -EINVAL; | 165 | return -EINVAL; |
166 | 166 | ||
167 | len = nla_len(opt) - NLA_ALIGN(sizeof(*qopt)); | ||
167 | if (len > 0) { | 168 | if (len > 0) { |
168 | err = parse_attr(tb, TCA_MQPRIO_MAX, opt, mqprio_policy, | 169 | err = parse_attr(tb, TCA_MQPRIO_MAX, opt, mqprio_policy, |
169 | sizeof(*qopt)); | 170 | sizeof(*qopt)); |