Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic - If if_initialize() failed in the attach functio...
details: https://anonhg.NetBSD.org/src/rev/2166fdbf23d0
branches: trunk
changeset: 357011:2166fdbf23d0
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Mon Oct 23 09:27:46 2017 +0000
description:
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
failed.
diffstat:
sys/dev/ic/dwc_gmac.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diffs (56 lines):
diff -r ce42fa76bc75 -r 2166fdbf23d0 sys/dev/ic/dwc_gmac.c
--- a/sys/dev/ic/dwc_gmac.c Mon Oct 23 09:27:21 2017 +0000
+++ b/sys/dev/ic/dwc_gmac.c Mon Oct 23 09:27:46 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.40 2017/02/20 07:43:29 ozaki-r Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.41 2017/10/23 09:27:46 msaitoh Exp $ */
/*-
* Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.40 2017/02/20 07:43:29 ozaki-r Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.41 2017/10/23 09:27:46 msaitoh Exp $");
/* #define DWC_GMAC_DEBUG 1 */
@@ -146,6 +146,7 @@
struct mii_data * const mii = &sc->sc_mii;
struct ifnet * const ifp = &sc->sc_ec.ec_if;
prop_dictionary_t dict;
+ int rv;
mutex_init(&sc->sc_mdio_lock, MUTEX_DEFAULT, IPL_NET);
sc->sc_mii_clk = mii_clk & 7;
@@ -259,7 +260,9 @@
* Ready, attach interface
*/
/* Attach the interface. */
- if_initialize(ifp);
+ rv = if_initialize(ifp);
+ if (rv != 0)
+ goto fail_2;
sc->sc_ipq = if_percpuq_create(&sc->sc_ec.ec_if);
if_deferred_start_init(ifp, NULL);
ether_ifattach(ifp, enaddr);
@@ -277,10 +280,17 @@
mutex_exit(sc->sc_lock);
return;
-
+fail_2:
+ ifmedia_removeall(&mii->mii_media);
+ mii_detach(&mii, MII_PHY_ANY, MII_OFFSET_ANY);
+ mutex_destroy(&sc->sc_txq.t_mtx);
+ mutex_destroy(&sc->sc_rxq.r_mtx);
+ mutex_obj_free(sc->sc_lock);
fail:
dwc_gmac_free_rx_ring(sc, &sc->sc_rxq);
dwc_gmac_free_tx_ring(sc, &sc->sc_txq);
+ dwc_gmac_free_dma_rings(sc);
+ mutex_destroy(&sc->sc_mdio_lock);
}
Home |
Main Index |
Thread Index |
Old Index