diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-04-11 21:39:15 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-04-11 21:39:15 +0000 |
commit | 1d3fc06eb4e2e6860d4fe2b25e6a37cf187e44b5 (patch) | |
tree | 7c2c2f4ebbb863b2977eaf1e3699b3f9cc14ab03 /sys/dev/pci/if_cas.c | |
parent | baeb4026991c7ff4275043e45412654f10e20dd1 (diff) |
Check return value from m_devget().
Diffstat (limited to 'sys/dev/pci/if_cas.c')
-rw-r--r-- | sys/dev/pci/if_cas.c | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/sys/dev/pci/if_cas.c b/sys/dev/pci/if_cas.c index bc578ca9afc..13fa4c7669f 100644 --- a/sys/dev/pci/if_cas.c +++ b/sys/dev/pci/if_cas.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cas.c,v 1.4 2007/02/27 21:19:40 kettenis Exp $ */ +/* $OpenBSD: if_cas.c,v 1.5 2007/04/11 21:39:14 kettenis Exp $ */ /* * @@ -1126,22 +1126,26 @@ cas_rint(struct cas_softc *sc) cp = rxs->rxs_kva + off * 256; m = m_devget(cp, len + ETHER_ALIGN, 0, ifp, NULL); - m_adj(m, ETHER_ALIGN); - + if (word[0] & CAS_RC0_RELEASE_HDR) cas_add_rxbuf(sc, idx); + if (m != NULL) { + m_adj(m, ETHER_ALIGN); + #if NBPFILTER > 0 - /* - * Pass this up to any BPF listeners, but only - * pass it up the stack if its for us. - */ - if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + /* + * Pass this up to any BPF listeners, but only + * pass it up the stack if its for us. + */ + if (ifp->if_bpf) + bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); #endif /* NPBFILTER > 0 */ - ifp->if_ipackets++; - ether_input_mbuf(ifp, m); + ifp->if_ipackets++; + ether_input_mbuf(ifp, m); + } else + ifp->if_ierrors++; } len = CAS_RC0_DATA_LEN(word[0]); @@ -1159,22 +1163,26 @@ cas_rint(struct cas_softc *sc) /* XXX We should not be copying the packet here. */ cp = rxs->rxs_kva + off; m = m_devget(cp, len + ETHER_ALIGN, 0, ifp, NULL); - m_adj(m, ETHER_ALIGN); if (word[0] & CAS_RC0_RELEASE_DATA) cas_add_rxbuf(sc, idx); + if (m != NULL) { + m_adj(m, ETHER_ALIGN); + #if NBPFILTER > 0 - /* - * Pass this up to any BPF listeners, but only - * pass it up the stack if its for us. - */ - if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + /* + * Pass this up to any BPF listeners, but only + * pass it up the stack if its for us. + */ + if (ifp->if_bpf) + bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); #endif /* NPBFILTER > 0 */ - ifp->if_ipackets++; - ether_input_mbuf(ifp, m); + ifp->if_ipackets++; + ether_input_mbuf(ifp, m); + } else + ifp->if_ierrors++; } if (word[0] & CAS_RC0_SPLIT) |