[PATCH][next] taprio: add null check on sched_nest to avoid potential null pointer dereference
From: Colin King
Date: Sun May 05 2019 - 17:51:05 EST
From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
The call to nla_nest_start_noflag can return a null pointer and currently
this is not being checked and this can lead to a null pointer dereference
when the null pointer sched_nest is passed to function nla_nest_end. Fix
this by adding in a null pointer check.
Addresses-Coverity: ("Dereference null return value")
Fixes: a3d43c0d56f1 ("taprio: Add support adding an admin schedule")
Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
---
net/sched/sch_taprio.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 539677120b9f..9ecfb8f5902a 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -1087,6 +1087,8 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb)
goto done;
sched_nest = nla_nest_start_noflag(skb, TCA_TAPRIO_ATTR_ADMIN_SCHED);
+ if (!sched_nest)
+ goto options_error;
if (dump_schedule(skb, admin))
goto admin_error;
--
2.20.1