aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2022-04-21 12:40:32 +0000
committerKristof Provost <kp@FreeBSD.org>2022-04-27 06:49:25 +0000
commitf3b722fed330ee3a08a21947d6b4cf2fb70cc562 (patch)
treec898a851d6b0395bc4f035054dd7f796d4246c1a
parent5bc3ab86d6191b1f96f2bc7011314d43c32492f3 (diff)
pfsync: NULL check before dereference
Move the use of 'sc' to after the NULL check. It's very unlikely that we'd actually hit this, but Coverity is correct that it's not a good idea to dereference the pointer and only then NULL check it. Reported by: Coverity (CID 1398362) MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 43020350635150eeb439c035f608ec9e78ddff8f)
-rw-r--r--sys/netpfil/pf/if_pfsync.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
index cc053b53204a..470c2f176328 100644
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -1737,7 +1737,7 @@ pfsync_defer(struct pf_kstate *st, struct mbuf *m)
{
struct pfsync_softc *sc = V_pfsyncif;
struct pfsync_deferral *pd;
- struct pfsync_bucket *b = pfsync_get_bucket(sc, st);
+ struct pfsync_bucket *b;
if (m->m_flags & (M_BCAST|M_MCAST))
return (0);
@@ -1745,6 +1745,8 @@ pfsync_defer(struct pf_kstate *st, struct mbuf *m)
if (sc == NULL)
return (0);
+ b = pfsync_get_bucket(sc, st);
+
PFSYNC_LOCK(sc);
if (!(sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING) ||