diff --git a/sys/netgraph/fec/ng_fec.c b/sys/netgraph/fec/ng_fec.c @@ -948,6 +948,15 @@ } /* + * The computed port index may select a slot whose member interface + * was removed by ng_fec_delport() (fec_idx is never renumbered), in + * which case the foreach terminates with p == NULL. Bail out instead + * of dereferencing NULL below. + */ + if (p == NULL) + return(EINVAL); + + /* * Now that we've chosen a port, make sure it's * alive. If it's not alive, cycle through the bundle * looking for a port that is alive. If we don't find