qfq: don't leak skb if kzalloc fails
Subsystems (3)
PATCH 1/1 qfq: don't leak skb if kzalloc fails
When we need to create a new aggregate to enqueue the skb we need to kzalloc the new struct.
If that fails we returned ENOBUFS without freeing the skb.
Spotted during code review.
--- net/sched/sch_qfq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_qfq.c +1 -1
@@ -1236,7 +1236,7 @@ static int qfq_enqueue(struct sk_buff *skb, struct Qdisc *sch) err =qfq_change_agg (sch, cl, cl->agg->class_weight,qdisc_pkt_len (skb));if (err) -return err; +return qdisc_drop (skb, sch); } err =qdisc_enqueue (skb, cl->qdisc);
Signature · 1 line
2.7.3
Quoted 17 lines · Florian Westphal
When we need to create a new aggregate to enqueue the skb we need to kzalloc the new struct.
If that fails we returned ENOBUFS without freeing the skb.
Spotted during code review.
Signed-off-by Florian Westphal <[email protected]>--- net/sched/sch_qfq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/sched/sch_qfq.c +0
-0
net/sched/sch_qfq.c static int qfq_enqueue(struct sk_buff *skb, struct Qdisc *sch) · line 1242
Quoted 8 lines
net/sched/sch_qfq.c +1
-1@@ -1236,7 +1236,7 @@ static int qfq_enqueue(struct sk_buff *skb, struct Qdisc *sch) err =qfq_change_agg (sch, cl, cl->agg->class_weight,qdisc_pkt_len (skb));if (err) -return err; +return qdisc_drop (skb, sch); } err =qdisc_enqueue (skb, cl->qdisc);
Good catch, but it looks like you forgot :
cl->qstats.drops++;
Quoted 25 lines · Eric Dumazet
Quoted 24 lines · Florian Westphal
When we need to create a new aggregate to enqueue the skb we need to kzalloc the new struct.
If that fails we returned ENOBUFS without freeing the skb.
Spotted during code review.
Signed-off-by Florian Westphal <[email protected]>--- net/sched/sch_qfq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/sched/sch_qfq.c +1
-1@@ -1236,7 +1236,7 @@ static int qfq_enqueue(struct sk_buff *skb, struct Qdisc *sch) err =qfq_change_agg (sch, cl, cl->agg->class_weight,qdisc_pkt_len (skb));if (err) -return err; +return qdisc_drop (skb, sch); }
Quoted 5 lines
net/sched/sch_qfq.c static int qfq_enqueue(struct sk_buff *skb, struct Qdisc *sch) · line 1242
Quoted 1 line
net/sched/sch_qfq.c +0
-0err =qdisc_enqueue (skb, cl->qdisc);Good catch, but it looks like you forgot :
cl->qstats.drops++;
Thanks, we have too many stats :-/
I'll send a v2, thanks!