From owner-svn-src-all@FreeBSD.ORG Fri Jun 11 22:01:58 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 67EA61065673; Fri, 11 Jun 2010 22:01:58 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 561FA8FC1B; Fri, 11 Jun 2010 22:01:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o5BM1wdV002739; Fri, 11 Jun 2010 22:01:58 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o5BM1wBI002737; Fri, 11 Jun 2010 22:01:58 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201006112201.o5BM1wBI002737@svn.freebsd.org> From: Marius Strobl Date: Fri, 11 Jun 2010 22:01:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r209075 - stable/8/sys/dev/cas X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jun 2010 22:01:58 -0000 Author: marius Date: Fri Jun 11 22:01:58 2010 New Revision: 209075 URL: http://svn.freebsd.org/changeset/base/209075 Log: MFC: r208776 Avoid possible NULL-dereferences. Found with: Coverity Prevent(tm) CID: 3428 Approved by: re (kib) Modified: stable/8/sys/dev/cas/if_cas.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/geom/sched/ (props changed) Modified: stable/8/sys/dev/cas/if_cas.c ============================================================================== --- stable/8/sys/dev/cas/if_cas.c Fri Jun 11 21:54:06 2010 (r209074) +++ stable/8/sys/dev/cas/if_cas.c Fri Jun 11 22:01:58 2010 (r209075) @@ -1787,6 +1787,7 @@ cas_rint(struct cas_softc *sc) } } idx2 = 0; + m2 = NULL; rxds2 = NULL; if ((word1 & CAS_RC1_SPLIT_PKT) != 0) { KASSERT((word1 & CAS_RC1_RELEASE_NEXT) != 0, @@ -1799,32 +1800,39 @@ cas_rint(struct cas_softc *sc) __func__, idx2); #endif rxds2 = &sc->sc_rxdsoft[idx2]; - MGET(m2, M_DONTWAIT, MT_DATA); - if (m2 != NULL) { - refcount_acquire( - &rxds2->rxds_refcount); - m2->m_len = len - m->m_len; - bus_dmamap_sync(sc->sc_rdmatag, - rxds2->rxds_dmamap, - BUS_DMASYNC_POSTREAD); + if (m != NULL) { + MGET(m2, M_DONTWAIT, MT_DATA); + if (m2 != NULL) { + refcount_acquire( + &rxds2->rxds_refcount); + m2->m_len = len - m->m_len; + bus_dmamap_sync( + sc->sc_rdmatag, + rxds2->rxds_dmamap, + BUS_DMASYNC_POSTREAD); #if __FreeBSD_version < 800016 - MEXTADD(m2, (caddr_t)rxds2->rxds_buf, - m2->m_len, cas_free, rxds2, - M_RDONLY, EXT_NET_DRV); + MEXTADD(m2, + (caddr_t)rxds2->rxds_buf, + m2->m_len, cas_free, + rxds2, M_RDONLY, + EXT_NET_DRV); #else - MEXTADD(m2, (caddr_t)rxds2->rxds_buf, - m2->m_len, cas_free, - sc, (void *)(uintptr_t)idx2, - M_RDONLY, EXT_NET_DRV); + MEXTADD(m2, + (caddr_t)rxds2->rxds_buf, + m2->m_len, cas_free, sc, + (void *)(uintptr_t)idx2, + M_RDONLY, EXT_NET_DRV); #endif - if ((m2->m_flags & M_EXT) == 0) { - m_freem(m2); - m2 = NULL; + if ((m2->m_flags & M_EXT) == + 0) { + m_freem(m2); + m2 = NULL; + } } } if (m2 != NULL) m->m_next = m2; - else { + else if (m != NULL) { m_freem(m); m = NULL; }