Skip to content

Commit 1df94c3

Browse files
congwangdavem330
authored andcommitted
net_sched: properly check for empty skb array on error path
First, the check of &q->ring.queue against NULL is wrong, it is always false. We should check the value rather than the address. Secondly, we need the same check in pfifo_fast_reset() too, as both ->reset() and ->destroy() are called in qdisc_destroy(). Fixes: c5ad119 ("net: sched: pfifo_fast use skb_array") Reported-by: syzbot <[email protected]> Cc: John Fastabend <[email protected]> Signed-off-by: Cong Wang <[email protected]> Acked-by: John Fastabend <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4eb50ce commit 1df94c3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

net/sched/sch_generic.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,12 @@ static void pfifo_fast_reset(struct Qdisc *qdisc)
659659
struct skb_array *q = band2list(priv, band);
660660
struct sk_buff *skb;
661661

662+
/* NULL ring is possible if destroy path is due to a failed
663+
* skb_array_init() in pfifo_fast_init() case.
664+
*/
665+
if (!q->ring.queue)
666+
continue;
667+
662668
while ((skb = skb_array_consume_bh(q)) != NULL)
663669
kfree_skb(skb);
664670
}
@@ -719,7 +725,7 @@ static void pfifo_fast_destroy(struct Qdisc *sch)
719725
/* NULL ring is possible if destroy path is due to a failed
720726
* skb_array_init() in pfifo_fast_init() case.
721727
*/
722-
if (!&q->ring.queue)
728+
if (!q->ring.queue)
723729
continue;
724730
/* Destroy ring but no need to kfree_skb because a call to
725731
* pfifo_fast_reset() has already done that work.

0 commit comments

Comments
 (0)