git: 9dac026822ab - main - dummynet: dn_dequeue() may return NULL

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Fri, 28 Jan 2022 23:09:39 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=9dac026822ab57b544ee28b66a00e400b5ca9a99

commit 9dac026822ab57b544ee28b66a00e400b5ca9a99
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2022-01-28 10:10:04 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-01-28 22:09:08 +0000

    dummynet: dn_dequeue() may return NULL
    
    If there are no more entries, or if we fail to restore the rcvif of a
    queued mbuf dn_dequeue() can return NULL.
    Cope with this.
    
    Reviewed by:    glebius
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D34078
---
 sys/netpfil/ipfw/dn_sched_wf2q.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/netpfil/ipfw/dn_sched_wf2q.c b/sys/netpfil/ipfw/dn_sched_wf2q.c
index 7285df0d1d7d..c8a401193811 100644
--- a/sys/netpfil/ipfw/dn_sched_wf2q.c
+++ b/sys/netpfil/ipfw/dn_sched_wf2q.c
@@ -243,6 +243,8 @@ wf2qp_dequeue(struct dn_sch_inst *_si)
 	q = HEAP_TOP(sch)->object;
 	alg_fq = (struct wf2qp_queue *)q;
 	m = dn_dequeue(q);
+	if (m == NULL)
+		return NULL;
 	heap_extract(sch, NULL); /* Remove queue from heap. */
 	si->V += (uint64_t)(m->m_pkthdr.len) * si->inv_wsum;
 	alg_fq->S = alg_fq->F;  /* Update start time. */