svn commit: r230706 - stable/8/sys/dev/dc

Marius Strobl marius at FreeBSD.org
Sun Jan 29 00:50:51 UTC 2012


Author: marius
Date: Sun Jan 29 00:50:50 2012
New Revision: 230706
URL: http://svn.freebsd.org/changeset/base/230706

Log:
  MFC: r227685
  
  - There's no need to ignore the return value of mii_attach(9) when attaching
    dcphy(4) (CID 9283).
  - In dc_detach(), check whether ifp is NULL as dc_attach() may call the
    former without ifp being allocated (CID 4288).
  
  Found with:	Coverity Prevent(tm)

Modified:
  stable/8/sys/dev/dc/if_dc.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)

Modified: stable/8/sys/dev/dc/if_dc.c
==============================================================================
--- stable/8/sys/dev/dc/if_dc.c	Sun Jan 29 00:50:41 2012	(r230705)
+++ stable/8/sys/dev/dc/if_dc.c	Sun Jan 29 00:50:50 2012	(r230706)
@@ -2456,9 +2456,6 @@ dc_attach(device_t dev)
 		if (sc->dc_pmode != DC_PMODE_SIA)
 			sc->dc_pmode = DC_PMODE_SYM;
 		sc->dc_flags |= DC_21143_NWAY;
-		mii_attach(dev, &sc->dc_miibus, ifp, dc_ifmedia_upd,
-		    dc_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY,
-		    MII_OFFSET_ANY, 0);
 		/*
 		 * For non-MII cards, we need to have the 21143
 		 * drive the LEDs. Except there are some systems
@@ -2469,7 +2466,9 @@ dc_attach(device_t dev)
 		if (!(pci_get_subvendor(dev) == 0x1033 &&
 		    pci_get_subdevice(dev) == 0x8028))
 			sc->dc_flags |= DC_TULIP_LEDS;
-		error = 0;
+		error = mii_attach(dev, &sc->dc_miibus, ifp, dc_ifmedia_upd,
+		    dc_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY,
+		    MII_OFFSET_ANY, 0);
 	}
 
 	if (error) {
@@ -2538,7 +2537,7 @@ dc_detach(device_t dev)
 	ifp = sc->dc_ifp;
 
 #ifdef DEVICE_POLLING
-	if (ifp->if_capenable & IFCAP_POLLING)
+	if (ifp != NULL && ifp->if_capenable & IFCAP_POLLING)
 		ether_poll_deregister(ifp);
 #endif
 
@@ -2562,7 +2561,7 @@ dc_detach(device_t dev)
 	if (sc->dc_res)
 		bus_release_resource(dev, DC_RES, DC_RID, sc->dc_res);
 
-	if (ifp)
+	if (ifp != NULL)
 		if_free(ifp);
 
 	dc_dma_free(sc);
@@ -2612,7 +2611,6 @@ dc_list_tx_init(struct dc_softc *sc)
 	return (0);
 }
 
-
 /*
  * Initialize the RX descriptors and allocate mbufs for them. Note that
  * we arrange the descriptors in a closed ring, so that the last descriptor


More information about the svn-src-stable mailing list