pfsync: NULL check sc before using it

In pfsync_defer() we must wait to lock sc until we've ensured it's not
NULL.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33240
This commit is contained in:
Kristof Provost 2021-12-02 14:32:21 +01:00
parent f499134dd4
commit 27bd812c5c

View File

@ -1739,9 +1739,12 @@ pfsync_defer(struct pf_kstate *st, struct mbuf *m)
if (m->m_flags & (M_BCAST|M_MCAST)) if (m->m_flags & (M_BCAST|M_MCAST))
return (0); return (0);
if (sc == NULL)
return (0);
PFSYNC_LOCK(sc); PFSYNC_LOCK(sc);
if (sc == NULL || !(sc->sc_ifp->if_flags & IFF_DRV_RUNNING) || if (!(sc->sc_ifp->if_flags & IFF_DRV_RUNNING) ||
!(sc->sc_flags & PFSYNCF_DEFER)) { !(sc->sc_flags & PFSYNCF_DEFER)) {
PFSYNC_UNLOCK(sc); PFSYNC_UNLOCK(sc);
return (0); return (0);