Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci - If if_initialize() failed in the attach functi...
details: https://anonhg.NetBSD.org/src/rev/dac77e326826
branches: trunk
changeset: 357012:dac77e326826
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Mon Oct 23 09:28:13 2017 +0000
description:
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
diffstat:
sys/dev/pci/if_iwi.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diffs (55 lines):
diff -r 2166fdbf23d0 -r dac77e326826 sys/dev/pci/if_iwi.c
--- a/sys/dev/pci/if_iwi.c Mon Oct 23 09:27:46 2017 +0000
+++ b/sys/dev/pci/if_iwi.c Mon Oct 23 09:28:13 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_iwi.c,v 1.103 2017/05/23 02:19:14 ozaki-r Exp $ */
+/* $NetBSD: if_iwi.c,v 1.104 2017/10/23 09:28:13 msaitoh Exp $ */
/* $OpenBSD: if_iwi.c,v 1.111 2010/11/15 19:11:57 damien Exp $ */
/*-
@@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.103 2017/05/23 02:19:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.104 2017/10/23 09:28:13 msaitoh Exp $");
/*-
* Intel(R) PRO/Wireless 2200BG/2225BG/2915ABG driver
@@ -367,7 +367,13 @@
IFQ_SET_READY(&ifp->if_snd);
memcpy(ifp->if_xname, device_xname(self), IFNAMSIZ);
- if_initialize(ifp);
+ error = if_initialize(ifp);
+ if (error != 0) {
+ ifp->if_softc = NULL; /* For iwi_detach() */
+ aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n",
+ error);
+ goto fail;
+ }
ieee80211_ifattach(ic);
/* Use common softint-based if_input */
ifp->if_percpuq = if_percpuq_create(ifp);
@@ -454,16 +460,13 @@
struct iwi_softc *sc = device_private(self);
struct ifnet *ifp = &sc->sc_if;
- pmf_device_deregister(self);
-
- if (ifp != NULL)
+ if (ifp->if_softc != NULL) {
+ pmf_device_deregister(self);
iwi_stop(ifp, 1);
-
- iwi_free_firmware(sc);
-
- ieee80211_ifdetach(&sc->sc_ic);
- if (ifp != NULL)
+ iwi_free_firmware(sc);
+ ieee80211_ifdetach(&sc->sc_ic);
if_detach(ifp);
+ }
iwi_free_cmd_ring(sc, &sc->cmdq);
iwi_free_tx_ring(sc, &sc->txq[0]);
Home |
Main Index |
Thread Index |
Old Index