Skip to contentSkip to conversation

qfq: don't leak skb if kzalloc fails

PATCH Applied Florian Westphal 2 participants 2 messages Jun 8, 2016 – Jun 9, 2016

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

PATCH v2 1/1 qfq: don't leak skb if kzalloc fails

When we need to create a new aggregate to enqueue the skb we call kzalloc. If that fails we returned ENOBUFS without freeing the skb.

Spotted during code review.

---
V2: also increment cl->qstats.drops

 net/sched/sch_qfq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/sched/sch_qfq.c +4 -2
index 8d2d8d9..f18857f 100644
@@ -1235,8 +1235,10 @@ static int qfq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 			 cl->agg->lmax, qdisc_pkt_len(skb), cl->common.classid);
 		err = qfq_change_agg(sch, cl, cl->agg->class_weight,
 				     qdisc_pkt_len(skb));
-		if (err)
-			return err;
+		if (err) {
+			cl->qstats.drops++;
+			return qdisc_drop(skb, sch);
+		}
 	}
 
 	err = qdisc_enqueue(skb, cl->qdisc);
Signature · 1 line
2.7.3
maintainer Applied
#1 lore raw

From: Florian Westphal <[email protected]>
Date: Wed, 8 Jun 2016 23:23:01 +0200

Quoted 6 lines

When we need to create a new aggregate to enqueue the skb we call kzalloc. If that fails we returned ENOBUFS without freeing the skb.

Spotted during code review.

Applied.