[PATCH v2 net] qfq: don't leak skb if kzalloc fails

Subsystems: networking [general], tc subsystem, the rest

STALE3709d

2 messages, 2 authors, 2016-06-09 · open the first message on its own page

[PATCH v2 net] qfq: don't leak skb if kzalloc fails

From: Florian Westphal <fw@strlen.de>
Date: 2016-06-08 21:22:51

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.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 V2: also increment cl->qstats.drops

 net/sched/sch_qfq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
index 8d2d8d9..f18857f 100644
--- a/net/sched/sch_qfq.c
+++ b/net/sched/sch_qfq.c
@@ -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);
-- 
2.7.3

Re: [PATCH v2 net] qfq: don't leak skb if kzalloc fails

From: David Miller <davem@davemloft.net>
Date: 2016-06-09 05:42:02

From: Florian Westphal <fw@strlen.de>
Date: Wed,  8 Jun 2016 23:23:01 +0200
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.

Signed-off-by: Florian Westphal <fw@strlen.de>
Applied.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help