aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Strobl <marius@FreeBSD.org>2011-11-18 21:22:43 +0000
committerMarius Strobl <marius@FreeBSD.org>2011-11-18 21:22:43 +0000
commit166e31d988b6f5a5383018797d03ef4ab1820c13 (patch)
tree4c317ab664c421b22cb220e0cbeb3c40bcc0782b
parent89b2411bc3b8d8efe9e4337974dcd029d639cf38 (diff)
downloadsrc-166e31d988b6f5a5383018797d03ef4ab1820c13.tar.gz
src-166e31d988b6f5a5383018797d03ef4ab1820c13.zip
- 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)
Notes
Notes: svn path=/head/; revision=227685
-rw-r--r--sys/dev/dc/if_dc.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c
index 803d115f4aaf..b9ea19ae4bcc 100644
--- a/sys/dev/dc/if_dc.c
+++ b/sys/dev/dc/if_dc.c
@@ -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