From 60d63461a21e4ba80eae9df4eb31ca666d333c55 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Tue, 29 Nov 2016 10:22:31 +0000 Subject: m_free() and m_freem() test for NULL. Simplify callers which had their own NULL tests. ok mpi@ --- sys/arch/sgi/dev/if_iec.c | 5 ++--- sys/arch/sgi/hpc/if_sq.c | 5 ++--- sys/dev/ic/ar5008.c | 5 ++--- sys/dev/ic/ar9003.c | 5 ++--- sys/dev/ic/dwc_gmac.c | 5 ++--- sys/dev/ic/pgt.c | 8 +++----- sys/dev/pci/hifn7751.c | 5 ++--- sys/dev/pci/if_alc.c | 8 +++----- sys/dev/pci/if_ixgb.c | 5 ++--- sys/dev/pci/if_jme.c | 11 ++++------- sys/dev/pci/if_nfe.c | 5 ++--- sys/dev/pci/if_pcn.c | 5 ++--- sys/dev/pci/if_stge.c | 5 ++--- sys/dev/pci/if_xge.c | 5 ++--- sys/dev/usb/if_athn_usb.c | 5 ++--- sys/kern/uipc_mbuf.c | 5 ++--- sys/kern/uipc_socket.c | 11 ++++------- sys/kern/uipc_syscalls.c | 5 ++--- sys/kern/uipc_usrreq.c | 8 +++----- sys/net/pfkey.c | 5 ++--- sys/net/route.c | 5 ++--- sys/net/rtsock.c | 5 ++--- sys/netinet/ip_mroute.c | 5 ++--- 23 files changed, 53 insertions(+), 83 deletions(-) (limited to 'sys') diff --git a/sys/arch/sgi/dev/if_iec.c b/sys/arch/sgi/dev/if_iec.c index 73c74b209e9..4b5c2636db3 100644 --- a/sys/arch/sgi/dev/if_iec.c +++ b/sys/arch/sgi/dev/if_iec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iec.c,v 1.21 2016/04/13 11:34:00 mpi Exp $ */ +/* $OpenBSD: if_iec.c,v 1.22 2016/11/29 10:22:30 jsg Exp $ */ /* * Copyright (c) 2009 Miodrag Vallat. @@ -1160,8 +1160,7 @@ iec_get(struct iec_softc *sc, uint8_t *data, size_t datalen) if ((m->m_flags & M_EXT) == 0) { printf("%s: unable to allocate RX cluster\n", sc->sc_dev.dv_xname); - if (head != NULL) - m_freem(head); + m_freem(head); return NULL; } len = MCLBYTES; diff --git a/sys/arch/sgi/hpc/if_sq.c b/sys/arch/sgi/hpc/if_sq.c index 6f2aa7ad2af..b34677074e9 100644 --- a/sys/arch/sgi/hpc/if_sq.c +++ b/sys/arch/sgi/hpc/if_sq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sq.c,v 1.26 2016/04/13 11:34:00 mpi Exp $ */ +/* $OpenBSD: if_sq.c,v 1.27 2016/11/29 10:22:30 jsg Exp $ */ /* $NetBSD: if_sq.c,v 1.42 2011/07/01 18:53:47 dyoung Exp $ */ /* @@ -747,8 +747,7 @@ sq_start(struct ifnet *ifp) */ ifq_set_oactive(&ifp->if_snd); bus_dmamap_unload(sc->sc_dmat, dmamap); - if (m != NULL) - m_freem(m); + m_freem(m); break; } diff --git a/sys/dev/ic/ar5008.c b/sys/dev/ic/ar5008.c index 590de9e4b5c..5de3a212ec4 100644 --- a/sys/dev/ic/ar5008.c +++ b/sys/dev/ic/ar5008.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5008.c,v 1.36 2016/10/08 14:35:56 stsp Exp $ */ +/* $OpenBSD: ar5008.c,v 1.37 2016/11/29 10:22:30 jsg Exp $ */ /*- * Copyright (c) 2009 Damien Bergamini @@ -649,8 +649,7 @@ ar5008_rx_free(struct athn_softc *sc) if (bf->bf_map != NULL) bus_dmamap_destroy(sc->sc_dmat, bf->bf_map); - if (bf->bf_m != NULL) - m_freem(bf->bf_m); + m_freem(bf->bf_m); } free(rxq->bf, M_DEVBUF, 0); diff --git a/sys/dev/ic/ar9003.c b/sys/dev/ic/ar9003.c index 51b5d76c674..76b06d4ff54 100644 --- a/sys/dev/ic/ar9003.c +++ b/sys/dev/ic/ar9003.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar9003.c,v 1.40 2016/10/08 14:35:56 stsp Exp $ */ +/* $OpenBSD: ar9003.c,v 1.41 2016/11/29 10:22:30 jsg Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini @@ -785,8 +785,7 @@ ar9003_rx_free(struct athn_softc *sc, int qid) if (bf->bf_map != NULL) bus_dmamap_destroy(sc->sc_dmat, bf->bf_map); - if (bf->bf_m != NULL) - m_freem(bf->bf_m); + m_freem(bf->bf_m); } free(rxq->bf, M_DEVBUF, 0); } diff --git a/sys/dev/ic/dwc_gmac.c b/sys/dev/ic/dwc_gmac.c index 2f222d29cc4..5895dc7a39d 100644 --- a/sys/dev/ic/dwc_gmac.c +++ b/sys/dev/ic/dwc_gmac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc_gmac.c,v 1.3 2016/10/08 11:20:26 kettenis Exp $ */ +/* $OpenBSD: dwc_gmac.c,v 1.4 2016/11/29 10:22:30 jsg Exp $ */ /* $NetBSD: dwc_gmac.c,v 1.34 2015/08/21 20:12:29 jmcneill Exp $ */ /*- @@ -564,8 +564,7 @@ dwc_gmac_free_rx_ring(struct dwc_gmac_softc *sc, struct dwc_gmac_rx_ring *ring) bus_dmamap_unload(sc->sc_dmat, data->rd_map); bus_dmamap_destroy(sc->sc_dmat, data->rd_map); } - if (data->rd_m != NULL) - m_freem(data->rd_m); + m_freem(data->rd_m); } } diff --git a/sys/dev/ic/pgt.c b/sys/dev/ic/pgt.c index 7d4ffd380c3..edb9624520d 100644 --- a/sys/dev/ic/pgt.c +++ b/sys/dev/ic/pgt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pgt.c,v 1.87 2016/04/13 10:49:26 mpi Exp $ */ +/* $OpenBSD: pgt.c,v 1.88 2016/11/29 10:22:30 jsg Exp $ */ /* * Copyright (c) 2006 Claudio Jeker @@ -1538,8 +1538,7 @@ fail: pgt_reinit_rx_desc_frag(sc, pd); ifp->if_ierrors++; - if (top) - m_freem(top); + m_freem(top); return (NULL); } @@ -2224,8 +2223,7 @@ pgt_start(struct ifnet *ifp) } } #endif - if (m != NULL) - m_freem(m); + m_freem(m); } } } diff --git a/sys/dev/pci/hifn7751.c b/sys/dev/pci/hifn7751.c index e3331572720..5436723128f 100644 --- a/sys/dev/pci/hifn7751.c +++ b/sys/dev/pci/hifn7751.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hifn7751.c,v 1.174 2015/12/10 21:00:51 naddy Exp $ */ +/* $OpenBSD: hifn7751.c,v 1.175 2016/11/29 10:22:30 jsg Exp $ */ /* * Invertex AEON / Hifn 7751 driver @@ -2676,8 +2676,7 @@ out: bus_dmamap_unload(sc->sc_dmat, cmd->src_map); bus_dmamap_destroy(sc->sc_dmat, cmd->src_map); } - if (cmd->dstu.dst_m != NULL) - m_freem(cmd->dstu.dst_m); + m_freem(cmd->dstu.dst_m); explicit_bzero(cmd, sizeof(*cmd)); free(cmd, M_DEVBUF, sizeof *cmd); crp->crp_etype = err; diff --git a/sys/dev/pci/if_alc.c b/sys/dev/pci/if_alc.c index 5040f247c8e..67a47b9c018 100644 --- a/sys/dev/pci/if_alc.c +++ b/sys/dev/pci/if_alc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_alc.c,v 1.39 2016/04/13 10:34:32 mpi Exp $ */ +/* $OpenBSD: if_alc.c,v 1.40 2016/11/29 10:22:30 jsg Exp $ */ /*- * Copyright (c) 2009, Pyun YongHyeon * All rights reserved. @@ -1912,8 +1912,7 @@ alc_rxeof(struct alc_softc *sc, struct rx_rdesc *rrd) if (alc_newbuf(sc, rxd) != 0) { ifp->if_iqdrops++; /* Reuse Rx buffers. */ - if (sc->alc_cdata.alc_rxhead != NULL) - m_freem(sc->alc_cdata.alc_rxhead); + m_freem(sc->alc_cdata.alc_rxhead); break; } @@ -2377,8 +2376,7 @@ alc_stop(struct alc_softc *sc) CSR_WRITE_4(sc, ALC_INTR_STATUS, 0xFFFFFFFF); /* Reclaim Rx buffers that have been processed. */ - if (sc->alc_cdata.alc_rxhead != NULL) - m_freem(sc->alc_cdata.alc_rxhead); + m_freem(sc->alc_cdata.alc_rxhead); ALC_RXCHAIN_RESET(sc); /* * Free Tx/Rx mbufs still in the queues. diff --git a/sys/dev/pci/if_ixgb.c b/sys/dev/pci/if_ixgb.c index 02f96cc819f..2ee11993d47 100644 --- a/sys/dev/pci/if_ixgb.c +++ b/sys/dev/pci/if_ixgb.c @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ -/* $OpenBSD: if_ixgb.c,v 1.69 2016/04/13 10:34:32 mpi Exp $ */ +/* $OpenBSD: if_ixgb.c,v 1.70 2016/11/29 10:22:30 jsg Exp $ */ #include @@ -1786,8 +1786,7 @@ ixgb_rxeof(struct ixgb_softc *sc, int count) sc->rx_buffer_area[i].m_head = NULL; } else { sc->dropped_pkts++; - if (sc->fmp != NULL) - m_freem(sc->fmp); + m_freem(sc->fmp); sc->fmp = NULL; sc->lmp = NULL; } diff --git a/sys/dev/pci/if_jme.c b/sys/dev/pci/if_jme.c index 0173ee09de5..682cd490b03 100644 --- a/sys/dev/pci/if_jme.c +++ b/sys/dev/pci/if_jme.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_jme.c,v 1.47 2016/04/13 10:34:32 mpi Exp $ */ +/* $OpenBSD: if_jme.c,v 1.48 2016/11/29 10:22:30 jsg Exp $ */ /*- * Copyright (c) 2008, Pyun YongHyeon * All rights reserved. @@ -258,8 +258,7 @@ jme_miibus_statchg(struct device *dev) jme_stop_tx(sc); jme_rxeof(sc); - if (sc->jme_cdata.jme_rxhead != NULL) - m_freem(sc->jme_cdata.jme_rxhead); + m_freem(sc->jme_cdata.jme_rxhead); JME_RXCHAIN_RESET(sc); jme_txeof(sc); @@ -2042,8 +2041,7 @@ jme_stop(struct jme_softc *sc) #ifdef foo /* Reclaim Rx/Tx buffers that have been completed. */ jme_rxeof(sc); - if (sc->jme_cdata.jme_rxhead != NULL) - m_freem(sc->jme_cdata.jme_rxhead); + m_freem(sc->jme_cdata.jme_rxhead); JME_RXCHAIN_RESET(sc); jme_txeof(sc); #endif @@ -2051,8 +2049,7 @@ jme_stop(struct jme_softc *sc) /* * Free partial finished RX segments */ - if (sc->jme_cdata.jme_rxhead != NULL) - m_freem(sc->jme_cdata.jme_rxhead); + m_freem(sc->jme_cdata.jme_rxhead); JME_RXCHAIN_RESET(sc); /* diff --git a/sys/dev/pci/if_nfe.c b/sys/dev/pci/if_nfe.c index b19a8e516f8..daa894e4957 100644 --- a/sys/dev/pci/if_nfe.c +++ b/sys/dev/pci/if_nfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nfe.c,v 1.117 2016/04/13 10:34:32 mpi Exp $ */ +/* $OpenBSD: if_nfe.c,v 1.118 2016/11/29 10:22:30 jsg Exp $ */ /*- * Copyright (c) 2006, 2007 Damien Bergamini @@ -1318,8 +1318,7 @@ nfe_free_rx_ring(struct nfe_softc *sc, struct nfe_rx_ring *ring) bus_dmamap_unload(sc->sc_dmat, data->map); bus_dmamap_destroy(sc->sc_dmat, data->map); } - if (data->m != NULL) - m_freem(data->m); + m_freem(data->m); } } diff --git a/sys/dev/pci/if_pcn.c b/sys/dev/pci/if_pcn.c index 336af291763..b2adb5645bd 100644 --- a/sys/dev/pci/if_pcn.c +++ b/sys/dev/pci/if_pcn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pcn.c,v 1.41 2016/04/13 10:34:32 mpi Exp $ */ +/* $OpenBSD: if_pcn.c,v 1.42 2016/11/29 10:22:30 jsg Exp $ */ /* $NetBSD: if_pcn.c,v 1.26 2005/05/07 09:15:44 is Exp $ */ /* @@ -896,8 +896,7 @@ pcn_start(struct ifnet *ifp) */ ifq_set_oactive(&ifp->if_snd); bus_dmamap_unload(sc->sc_dmat, dmamap); - if (m != NULL) - m_freem(m); + m_freem(m); ifq_deq_rollback(&ifp->if_snd, m0); break; } diff --git a/sys/dev/pci/if_stge.c b/sys/dev/pci/if_stge.c index 4b486bcbffe..51ea9e5ef7f 100644 --- a/sys/dev/pci/if_stge.c +++ b/sys/dev/pci/if_stge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_stge.c,v 1.67 2016/04/13 10:34:32 mpi Exp $ */ +/* $OpenBSD: if_stge.c,v 1.68 2016/11/29 10:22:30 jsg Exp $ */ /* $NetBSD: if_stge.c,v 1.27 2005/05/16 21:35:32 bouyer Exp $ */ /*- @@ -889,8 +889,7 @@ stge_rxintr(struct stge_softc *sc) STGE_INIT_RXDESC(sc, i); if ((status & RFD_FrameEnd) == 0) sc->sc_rxdiscard = 1; - if (sc->sc_rxhead != NULL) - m_freem(sc->sc_rxhead); + m_freem(sc->sc_rxhead); STGE_RXCHAIN_RESET(sc); continue; } diff --git a/sys/dev/pci/if_xge.c b/sys/dev/pci/if_xge.c index 1aa6ddb071a..ddcaca5496b 100644 --- a/sys/dev/pci/if_xge.c +++ b/sys/dev/pci/if_xge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_xge.c,v 1.73 2016/05/16 04:34:25 dlg Exp $ */ +/* $OpenBSD: if_xge.c,v 1.74 2016/11/29 10:22:30 jsg Exp $ */ /* $NetBSD: if_xge.c,v 1.1 2005/09/09 10:30:27 ragge Exp $ */ /* @@ -1360,8 +1360,7 @@ xge_add_rxbuf(struct xge_softc *sc, int id) ((m[3]->m_flags & M_EXT) == 0) || ((m[4]->m_flags & M_EXT) == 0)) { /* Out of something */ for (i = 0; i < 5; i++) - if (m[i] != NULL) - m_free(m[i]); + m_free(m[i]); return (ENOBUFS); } /* Link'em together */ diff --git a/sys/dev/usb/if_athn_usb.c b/sys/dev/usb/if_athn_usb.c index 987095a7017..0cb8a06ee05 100644 --- a/sys/dev/usb/if_athn_usb.c +++ b/sys/dev/usb/if_athn_usb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_athn_usb.c,v 1.42 2015/12/11 16:07:02 mpi Exp $ */ +/* $OpenBSD: if_athn_usb.c,v 1.43 2016/11/29 10:22:30 jsg Exp $ */ /*- * Copyright (c) 2011 Damien Bergamini @@ -2397,8 +2397,7 @@ athn_usb_stop(struct ifnet *ifp) splx(s); /* Flush Rx stream. */ - if (usc->rx_stream.m != NULL) - m_freem(usc->rx_stream.m); + m_freem(usc->rx_stream.m); usc->rx_stream.m = NULL; usc->rx_stream.left = 0; } diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 8fcdf0f1080..514e7c963ee 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.238 2016/11/09 08:55:11 mpi Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.239 2016/11/29 10:22:30 jsg Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -361,8 +361,7 @@ m_clget(struct mbuf *m, int how, u_int pktlen) } buf = pool_get(pp, how == M_WAIT ? PR_WAITOK : PR_NOWAIT); if (buf == NULL) { - if (m0) - m_freem(m0); + m_freem(m0); return (NULL); } diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 691ae2fb4f0..bc124753cc8 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.167 2016/11/23 13:05:53 bluhm Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.168 2016/11/29 10:22:30 jsg Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -500,10 +500,8 @@ release: so->so_state &= ~SS_ISSENDING; sbunlock(&so->so_snd); out: - if (top) - m_freem(top); - if (control) - m_freem(control); + m_freem(top); + m_freem(control); return (error); } @@ -664,8 +662,7 @@ soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio, m = m_free(m); } while (uio->uio_resid && error == 0 && m); bad: - if (m) - m_freem(m); + m_freem(m); return (error); } if (mp) diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 09d345491d7..11790a07a25 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_syscalls.c,v 1.141 2016/11/28 13:55:43 mpi Exp $ */ +/* $OpenBSD: uipc_syscalls.c,v 1.142 2016/11/29 10:22:30 jsg Exp $ */ /* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */ /* @@ -451,8 +451,7 @@ bad: if (!interrupted) so->so_state &= ~SS_ISCONNECTING; FRELE(fp, p); - if (nam) - m_freem(nam); + m_freem(nam); if (error == ERESTART) error = EINTR; return (error); diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index e0f7f27d944..37516bf55f8 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_usrreq.c,v 1.102 2016/08/26 07:12:30 guenther Exp $ */ +/* $OpenBSD: uipc_usrreq.c,v 1.103 2016/11/29 10:22:30 jsg Exp $ */ /* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */ /* @@ -321,10 +321,8 @@ uipc_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, panic("piusrreq"); } release: - if (control) - m_freem(control); - if (m) - m_freem(m); + m_freem(control); + m_freem(m); return (error); } diff --git a/sys/net/pfkey.c b/sys/net/pfkey.c index 8e32a5c3dd4..c1985567628 100644 --- a/sys/net/pfkey.c +++ b/sys/net/pfkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkey.c,v 1.32 2016/11/07 10:04:57 mpi Exp $ */ +/* $OpenBSD: pfkey.c,v 1.33 2016/11/29 10:22:30 jsg Exp $ */ /* * @(#)COPYRIGHT 1.1 (NRL) 17 January 1995 @@ -186,8 +186,7 @@ pfkey_output(struct mbuf *mbuf, struct socket *socket) message, mbuf->m_pkthdr.len); ret: - if (mbuf) - m_freem(mbuf); + m_freem(mbuf); return (error); } diff --git a/sys/net/route.c b/sys/net/route.c index ed85379ce6f..0152054428a 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.339 2016/11/21 10:30:42 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.340 2016/11/29 10:22:30 jsg Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -1279,8 +1279,7 @@ rt_ifa_del(struct ifaddr *ifa, int flags, struct sockaddr *dst) rt_sendaddrmsg(rt, RTM_DELADDR, ifa); rtfree(rt); } - if (m != NULL) - m_free(m); + m_free(m); return (error); } diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 8953a30a60b..b6dc80aadde 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.209 2016/11/21 09:09:06 mpi Exp $ */ +/* $OpenBSD: rtsock.c,v 1.210 2016/11/29 10:22:30 jsg Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -272,8 +272,7 @@ route_ctloutput(int op, struct socket *so, int level, int optname, error = ENOPROTOOPT; break; } - if (m) - m_free(m); + m_free(m); break; case PRCO_GETOPT: switch (optname) { diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 08eaaeb6d1b..b280844c82e 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_mroute.c,v 1.91 2016/09/24 18:39:48 tedu Exp $ */ +/* $OpenBSD: ip_mroute.c,v 1.92 2016/11/29 10:22:30 jsg Exp $ */ /* $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $ */ /* @@ -317,8 +317,7 @@ ip_mrouter_set(struct socket *so, int optname, struct mbuf **mp) break; } - if (*mp) - m_free(*mp); + m_free(*mp); return (error); } -- cgit v1.2.3