diff --git a/sys/netgraph/ng_UI.c b/sys/netgraph/ng_UI.c index f1e16d771948..085804f38ea3 100644 --- a/sys/netgraph/ng_UI.c +++ b/sys/netgraph/ng_UI.c @@ -178,8 +178,8 @@ ng_UI_rcvdata(hook_p hook, item_p item) if (hook == priv->downlink) { u_char *start, *ptr; - if (!m || (m->m_len < MAX_ENCAPS_HDR - && !(m = m_pullup(m, MAX_ENCAPS_HDR)))) + if (m->m_len < MAX_ENCAPS_HDR + && !(m = m_pullup(m, MAX_ENCAPS_HDR))) ERROUT(ENOBUFS); ptr = start = mtod(m, u_char *); diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index f50f5f2306cf..0616176570d0 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -2139,6 +2139,13 @@ ng_snd_item(item_p item, int queue) * the node is derivable from the hook. * References are held on both by the item. */ + + /* Protect nodes from sending NULL pointers + * to each other + */ + if (m == NULL) + return (EINVAL); + CHECK_DATA_MBUF(NGI_M(item)); if (hook == NULL) { NG_FREE_ITEM(item); diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c index 5df34578aaa9..aad13657b283 100644 --- a/sys/netgraph/ng_eiface.c +++ b/sys/netgraph/ng_eiface.c @@ -587,11 +587,6 @@ ng_eiface_rcvdata(hook_p hook, item_p item) /* Meta-data ends its life here... */ NG_FREE_ITEM(item); - if (m == NULL) - { - printf("ng_eiface: mbuf is null.\n"); - return (EINVAL); - } if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) { NG_FREE_M(m); return (ENETDOWN); diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index 078c235730c5..c25477a52875 100644 --- a/sys/netgraph/ng_iface.c +++ b/sys/netgraph/ng_iface.c @@ -746,8 +746,6 @@ ng_iface_rcvdata(hook_p hook, item_p item) /* Sanity checks */ KASSERT(iffam != NULL, ("%s: iffam", __func__)); M_ASSERTPKTHDR(m); - if (m == NULL) - return (EINVAL); if ((ifp->if_flags & IFF_UP) == 0) { NG_FREE_M(m); return (ENETDOWN); diff --git a/sys/netgraph/ng_rfc1490.c b/sys/netgraph/ng_rfc1490.c index 451828d4b0d7..ab6b4158fff8 100644 --- a/sys/netgraph/ng_rfc1490.c +++ b/sys/netgraph/ng_rfc1490.c @@ -316,8 +316,8 @@ ng_rfc1490_rcvdata(hook_p hook, item_p item) const u_char *start; const u_char *ptr; - if (!m || (m->m_len < MAX_ENCAPS_HDR - && !(m = m_pullup(m, MAX_ENCAPS_HDR)))) + if (m->m_len < MAX_ENCAPS_HDR + && !(m = m_pullup(m, MAX_ENCAPS_HDR))) ERROUT(ENOBUFS); ptr = start = mtod(m, const u_char *); diff --git a/sys/netgraph/ng_sppp.c b/sys/netgraph/ng_sppp.c index 8461f8b8dde9..3f3c97fe85a9 100644 --- a/sys/netgraph/ng_sppp.c +++ b/sys/netgraph/ng_sppp.c @@ -382,8 +382,6 @@ ng_sppp_rcvdata (hook_p hook, item_p item) NG_FREE_ITEM (item); /* Sanity checks */ KASSERT (m->m_flags & M_PKTHDR, ("%s: not pkthdr", __func__)); - if (m == NULL) - return (EINVAL); if ((pp->pp_if.if_flags & IFF_UP) == 0) { NG_FREE_M (m); return (ENETDOWN);