Skip to contentSkip to conversation

net: sched: potential NULL dereference in tcf_block_find()

PATCH Applied Dan Carpenter 3 participants 3 messages Feb 18, 2019 – Feb 21, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: sched: potential NULL dereference in tcf_block_find()

The error code isn't set on this path so it would result in returning ERR_PTR(0) and a NULL dereference in the caller.

Fixes 18d3eefb17cf ("net: sched: refactor tcf_block_find() into standalone functions")
---
 net/sched/cls_api.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/sched/cls_api.c +3 -1
index 266fcb34fefe..aac72b853fe9 100644
@@ -1310,8 +1310,10 @@ static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q,
 		goto errout_qdisc;
 
 	block = __tcf_block_find(net, *q, *cl, ifindex, block_index, extack);
-	if (IS_ERR(block))
+	if (IS_ERR(block)) {
+		err = PTR_ERR(block);
 		goto errout_qdisc;
+	}
 
 	return block;
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 5 lines · Dan Carpenter

The error code isn't set on this path so it would result in returning ERR_PTR(0) and a NULL dereference in the caller.

Fixes 18d3eefb17cf ("net: sched: refactor tcf_block_find() into standalone functions")

Hi Dan,

Thank you for finding and fixing this!

Regards,
Vlad