summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormsaitoh <msaitoh@NetBSD.org>2017-10-23 09:31:17 +0000
committermsaitoh <msaitoh@NetBSD.org>2017-10-23 09:31:17 +0000
commit4cec6d9cb8de1b0b8ecf9bffdea9156c488dfd6d (patch)
treec1fbf974dd641cff1dfa324f2ea7746a0d63e050 /sys/dev
parent766faa964e36ca6d493d4da0f589620950c3db2d (diff)
If if_initialize() failed in the attach function, free resources and return.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/bwfm.c12
-rw-r--r--sys/dev/ic/malo.c17
-rw-r--r--sys/dev/ic/rt2560.c12
-rw-r--r--sys/dev/ic/rt2661.c12
-rw-r--r--sys/dev/ic/rt2860.c24
-rw-r--r--sys/dev/ic/rtw.c12
-rw-r--r--sys/dev/ic/rtwvar.h6
-rw-r--r--sys/dev/ic/wi.c15
-rw-r--r--sys/dev/pci/if_ipw.c12
-rw-r--r--sys/dev/pci/if_iwn.c12
-rw-r--r--sys/dev/pci/if_rtwn.c18
-rw-r--r--sys/dev/pci/if_wpi.c12
-rw-r--r--sys/dev/pci/ixgbe/ixgbe.c9
-rw-r--r--sys/dev/pci/ixgbe/ixv.c21
-rw-r--r--sys/dev/scsipi/if_se.c13
15 files changed, 157 insertions, 50 deletions
diff --git a/sys/dev/ic/bwfm.c b/sys/dev/ic/bwfm.c
index e80c44e6ea8..b608f2a5dee 100644
--- a/sys/dev/ic/bwfm.c
+++ b/sys/dev/ic/bwfm.c
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfm.c,v 1.2 2017/10/20 23:38:21 jmcneill Exp $ */
+/* $NetBSD: bwfm.c,v 1.3 2017/10/23 09:31:17 msaitoh Exp $ */
/* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
@@ -232,7 +232,15 @@ bwfm_attach(struct bwfm_softc *sc)
IFQ_SET_READY(&ifp->if_snd);
memcpy(ifp->if_xname, DEVNAME(sc), IFNAMSIZ);
- if_initialize(ifp);
+ error = if_initialize(ifp);
+ if (error != 0) {
+ printf("%s: if_initialize failed(%d)\n", DEVNAME(sc), error);
+ pcq_destroy(sc->sc_freetask);
+ workqueue_destroy(sc->sc_taskq);
+
+ return; /* Error */
+ }
+
ieee80211_ifattach(ic);
ifp->if_percpuq = if_percpuq_create(ifp);
if_deferred_start_init(ifp, NULL);
diff --git a/sys/dev/ic/malo.c b/sys/dev/ic/malo.c
index f61ae673071..1be86e6eaef 100644
--- a/sys/dev/ic/malo.c
+++ b/sys/dev/ic/malo.c
@@ -1,4 +1,4 @@
-/* $NetBSD: malo.c,v 1.9 2017/02/02 10:05:35 nonaka Exp $ */
+/* $NetBSD: malo.c,v 1.10 2017/10/23 09:31:17 msaitoh Exp $ */
/* $OpenBSD: malo.c,v 1.92 2010/08/27 17:08:00 jsg Exp $ */
/*
@@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: malo.c,v 1.9 2017/02/02 10:05:35 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: malo.c,v 1.10 2017/10/23 09:31:17 msaitoh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -366,7 +366,7 @@ malo_attach(struct malo_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ifnet *ifp = &sc->sc_if;
- int i;
+ int i, rv;
/* initialize channel scanning timer */
callout_init(&sc->sc_scan_to, 0);
@@ -422,7 +422,16 @@ malo_attach(struct malo_softc *sc)
aprint_normal(", address %s\n", ether_sprintf(ic->ic_myaddr));
/* attach interface */
- if_initialize(ifp);
+ rv = if_initialize(ifp);
+ if (rv != 0) {
+ aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", rv);
+ malo_free_tx_ring(sc, &sc->sc_txring);
+ malo_free_rx_ring(sc, &sc->sc_rxring);
+ malo_free_cmd(sc);
+ callout_destroy(&sc->sc_scan_to);
+
+ return rv; /* Error */
+ }
ieee80211_ifattach(ic);
/* Use common softint-based if_input */
ifp->if_percpuq = if_percpuq_create(ifp);
diff --git a/sys/dev/ic/rt2560.c b/sys/dev/ic/rt2560.c
index 279556877d3..2eaade2f328 100644
--- a/sys/dev/ic/rt2560.c
+++ b/sys/dev/ic/rt2560.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rt2560.c,v 1.30 2017/05/23 02:19:14 ozaki-r Exp $ */
+/* $NetBSD: rt2560.c,v 1.31 2017/10/23 09:31:17 msaitoh Exp $ */
/* $OpenBSD: rt2560.c,v 1.15 2006/04/20 20:31:12 miod Exp $ */
/* $FreeBSD: rt2560.c,v 1.3 2006/03/21 21:15:43 damien Exp $*/
@@ -24,7 +24,7 @@
* http://www.ralinktech.com/
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rt2560.c,v 1.30 2017/05/23 02:19:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rt2560.c,v 1.31 2017/10/23 09:31:17 msaitoh Exp $");
#include <sys/param.h>
@@ -453,7 +453,12 @@ rt2560_attach(void *xsc, int id)
IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ;
}
- if_initialize(ifp);
+ error = if_initialize(ifp);
+ if (error != 0) {
+ aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n",
+ error);
+ goto fail6;
+ }
ieee80211_ifattach(ic);
/* Use common softint-based if_input */
ifp->if_percpuq = if_percpuq_create(ifp);
@@ -492,6 +497,7 @@ rt2560_attach(void *xsc, int id)
return 0;
+fail6: rt2560_free_rx_ring(sc, &sc->rxq);
fail5: rt2560_free_tx_ring(sc, &sc->bcnq);
fail4: rt2560_free_tx_ring(sc, &sc->prioq);
fail3: rt2560_free_tx_ring(sc, &sc->atimq);
diff --git a/sys/dev/ic/rt2661.c b/sys/dev/ic/rt2661.c
index ffc65d2f10f..2be74b5e2f0 100644
--- a/sys/dev/ic/rt2661.c
+++ b/sys/dev/ic/rt2661.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rt2661.c,v 1.35 2017/05/23 02:19:14 ozaki-r Exp $ */
+/* $NetBSD: rt2661.c,v 1.36 2017/10/23 09:31:17 msaitoh Exp $ */
/* $OpenBSD: rt2661.c,v 1.17 2006/05/01 08:41:11 damien Exp $ */
/* $FreeBSD: rt2560.c,v 1.5 2006/06/02 19:59:31 csjp Exp $ */
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rt2661.c,v 1.35 2017/05/23 02:19:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rt2661.c,v 1.36 2017/10/23 09:31:17 msaitoh Exp $");
#include <sys/param.h>
@@ -342,7 +342,12 @@ rt2661_attach(void *xsc, int id)
IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ;
}
- if_initialize(ifp);
+ error = if_initialize(ifp);
+ if (error != 0) {
+ aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n",
+ error);
+ goto fail7;
+ }
ieee80211_ifattach(ic);
/* Use common softint-based if_input */
ifp->if_percpuq = if_percpuq_create(ifp);
@@ -380,6 +385,7 @@ rt2661_attach(void *xsc, int id)
return 0;
+fail7: rt2661_free_rx_ring(sc, &sc->rxq);
fail6: rt2661_free_tx_ring(sc, &sc->mgtq);
fail5: rt2661_free_tx_ring(sc, &sc->txq[3]);
fail4: rt2661_free_tx_ring(sc, &sc->txq[2]);
diff --git a/sys/dev/ic/rt2860.c b/sys/dev/ic/rt2860.c
index f78957721e1..c3abefeb531 100644
--- a/sys/dev/ic/rt2860.c
+++ b/sys/dev/ic/rt2860.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rt2860.c,v 1.28 2017/07/25 23:17:20 maya Exp $ */
+/* $NetBSD: rt2860.c,v 1.29 2017/10/23 09:31:17 msaitoh Exp $ */
/* $OpenBSD: rt2860.c,v 1.90 2016/04/13 10:49:26 mpi Exp $ */
/* $FreeBSD: head/sys/dev/ral/rt2860.c 306591 2016-10-02 20:35:55Z avos $ */
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.28 2017/07/25 23:17:20 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.29 2017/10/23 09:31:17 msaitoh Exp $");
#include <sys/param.h>
#include <sys/sockio.h>
@@ -401,7 +401,25 @@ rt2860_attachhook(device_t self)
IFQ_SET_READY(&ifp->if_snd);
memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
- if_initialize(ifp);
+ error = if_initialize(ifp);
+ if (error != 0) {
+ int qid;
+
+ aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n",
+ error);
+ for (qid = 0; qid < MAXQS; qid++)
+ rt2860_free_tx_ring(sc, &sc->txq[qid]);
+ rt2860_free_rx_ring(sc, &sc->rxq);
+ rt2860_free_tx_pool(sc);
+
+ if (sc->sc_soft_ih != NULL) {
+ softint_disestablish(sc->sc_soft_ih);
+ sc->sc_soft_ih = NULL;
+ }
+ if (sc->ucode != NULL)
+ firmware_free(sc->ucode, sc->ucsize);
+ return;
+ }
ieee80211_ifattach(ic);
/* Use common softint-based if_input */
ifp->if_percpuq = if_percpuq_create(ifp);
diff --git a/sys/dev/ic/rtw.c b/sys/dev/ic/rtw.c
index 83854e19c50..69581e02a18 100644
--- a/sys/dev/ic/rtw.c
+++ b/sys/dev/ic/rtw.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rtw.c,v 1.126 2017/05/23 02:19:14 ozaki-r Exp $ */
+/* $NetBSD: rtw.c,v 1.127 2017/10/23 09:31:17 msaitoh Exp $ */
/*-
* Copyright (c) 2004, 2005, 2006, 2007 David Young. All rights
* reserved.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.126 2017/05/23 02:19:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.127 2017/10/23 09:31:17 msaitoh Exp $");
#include <sys/param.h>
@@ -4225,11 +4225,16 @@ rtw_attach(struct rtw_softc *sc)
rtw_set80211props(&sc->sc_ic);
rtw_led_attach(&sc->sc_led_state, (void *)sc);
+ NEXT_ATTACH_STATE(sc, FINISH_LED_ATTACH);
/*
* Call MI attach routines.
*/
- if_initialize(ifp);
+ rc = if_initialize(ifp);
+ if (rc != 0) {
+ aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", rc);
+ goto err;
+ }
ieee80211_ifattach(ic);
/* Use common softint-based if_input */
ifp->if_percpuq = if_percpuq_create(ifp);
@@ -4276,6 +4281,7 @@ rtw_detach(struct rtw_softc *sc)
callout_stop(&sc->sc_scan_ch);
ieee80211_ifdetach(&sc->sc_ic);
if_detach(ifp);
+ case FINISH_LED_ATTACH:
rtw_led_detach(&sc->sc_led_state);
/*FALLTHROUGH*/
case FINISH_ID_STA:
diff --git a/sys/dev/ic/rtwvar.h b/sys/dev/ic/rtwvar.h
index 4f362eab3d6..89ac642b926 100644
--- a/sys/dev/ic/rtwvar.h
+++ b/sys/dev/ic/rtwvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rtwvar.h,v 1.45 2017/02/02 10:05:35 nonaka Exp $ */
+/* $NetBSD: rtwvar.h,v 1.46 2017/10/23 09:31:17 msaitoh Exp $ */
/*-
* Copyright (c) 2004, 2005 David Young. All rights reserved.
*
@@ -313,8 +313,8 @@ struct rtw_tx_radiotap_header {
enum rtw_attach_state {FINISHED, FINISH_DESCMAP_LOAD, FINISH_DESCMAP_CREATE,
FINISH_DESC_MAP, FINISH_DESC_ALLOC, FINISH_RXMAPS_CREATE,
FINISH_TXMAPS_CREATE, FINISH_RESET, FINISH_READ_SROM, FINISH_PARSE_SROM,
- FINISH_RF_ATTACH, FINISH_ID_STA, FINISH_TXDESCBLK_SETUP,
- FINISH_TXCTLBLK_SETUP, DETACHED};
+ FINISH_RF_ATTACH, FINISH_ID_STA, FINISH_LED_ATTACH,
+ FINISH_TXDESCBLK_SETUP, FINISH_TXCTLBLK_SETUP, DETACHED};
struct rtw_mtbl {
int (*mt_newstate)(struct ieee80211com *,
diff --git a/sys/dev/ic/wi.c b/sys/dev/ic/wi.c
index 8314f7fef73..aa7cc812e6d 100644
--- a/sys/dev/ic/wi.c
+++ b/sys/dev/ic/wi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: wi.c,v 1.243 2017/03/29 09:04:35 msaitoh Exp $ */
+/* $NetBSD: wi.c,v 1.244 2017/10/23 09:31:17 msaitoh Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -99,7 +99,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.243 2017/03/29 09:04:35 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.244 2017/10/23 09:31:17 msaitoh Exp $");
#define WI_HERMES_AUTOINC_WAR /* Work around data write autoinc bug. */
#define WI_HERMES_STATS_WAR /* Work around stats counter bug. */
@@ -373,7 +373,7 @@ wi_attach(struct wi_softc *sc, const u_int8_t *macaddr)
static const u_int8_t empty_macaddr[IEEE80211_ADDR_LEN] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
- int s;
+ int s, rv;
sc->sc_soft_ih = softint_establish(SOFTINT_NET, wi_softintr, sc);
if (sc->sc_soft_ih == NULL) {
@@ -550,7 +550,11 @@ wi_attach(struct wi_softc *sc, const u_int8_t *macaddr)
/*
* Call MI attach routines.
*/
- if_initialize(ifp);
+ rv = if_initialize(ifp);
+ if (rv != 0) {
+ aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", rv);
+ goto fail_2;
+ }
ieee80211_ifattach(ic);
/* Use common softint-based if_input */
ifp->if_percpuq = if_percpuq_create(ifp);
@@ -588,6 +592,9 @@ wi_attach(struct wi_softc *sc, const u_int8_t *macaddr)
ieee80211_announce(ic);
return 0;
+fail_2:
+ callout_destroy(&sc->sc_rssadapt_ch);
+
fail: splx(s);
softint_disestablish(sc->sc_soft_ih);
sc->sc_soft_ih = NULL;
diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c
index 20f50de4402..13d9d20638b 100644
--- a/sys/dev/pci/if_ipw.c
+++ b/sys/dev/pci/if_ipw.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ipw.c,v 1.65 2017/07/29 01:54:56 riastradh Exp $ */
+/* $NetBSD: if_ipw.c,v 1.66 2017/10/23 09:31:18 msaitoh Exp $ */
/* FreeBSD: src/sys/dev/ipw/if_ipw.c,v 1.15 2005/11/13 17:17:40 damien Exp */
/*-
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.65 2017/07/29 01:54:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.66 2017/10/23 09:31:18 msaitoh Exp $");
/*-
* Intel(R) PRO/Wireless 2100 MiniPCI driver
@@ -303,7 +303,13 @@ ipw_attach(device_t parent, device_t self, void *aux)
aprint_normal_dev(sc->sc_dev, "802.11 address %s\n",
ether_sprintf(ic->ic_myaddr));
- if_initialize(ifp);
+ error = if_initialize(ifp);
+ if (error != 0) {
+ ifp->if_softc = NULL; /* For ipw_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);
diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c
index e177d9b6343..b42e56cd889 100644
--- a/sys/dev/pci/if_iwn.c
+++ b/sys/dev/pci/if_iwn.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_iwn.c,v 1.85 2017/07/19 16:55:12 mlelstv Exp $ */
+/* $NetBSD: if_iwn.c,v 1.86 2017/10/23 09:31:18 msaitoh Exp $ */
/* $OpenBSD: if_iwn.c,v 1.135 2014/09/10 07:22:09 dcoppa Exp $ */
/*-
@@ -22,7 +22,7 @@
* adapters.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.85 2017/07/19 16:55:12 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.86 2017/10/23 09:31:18 msaitoh Exp $");
#define IWN_USE_RBUF /* Use local storage for RX */
#undef IWN_HWCRYPTO /* XXX does not even compile yet */
@@ -596,7 +596,12 @@ iwn_attach(device_t parent __unused, device_t self, void *aux)
IFQ_SET_READY(&ifp->if_snd);
memcpy(ifp->if_xname, device_xname(self), IFNAMSIZ);
- if_initialize(ifp);
+ error = if_initialize(ifp);
+ if (error != 0) {
+ aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n",
+ error);
+ goto fail5;
+ }
ieee80211_ifattach(ic);
/* Use common softint-based if_input */
ifp->if_percpuq = if_percpuq_create(ifp);
@@ -643,6 +648,7 @@ iwn_attach(device_t parent __unused, device_t self, void *aux)
return;
/* Free allocated memory if something failed during attachment. */
+fail5: iwn_free_rx_ring(sc, &sc->rxq);
fail4: while (--i >= 0)
iwn_free_tx_ring(sc, &sc->txq[i]);
#ifdef IWN_USE_RBUF
diff --git a/sys/dev/pci/if_rtwn.c b/sys/dev/pci/if_rtwn.c
index 9a77bb84d7e..047b27797b3 100644
--- a/sys/dev/pci/if_rtwn.c
+++ b/sys/dev/pci/if_rtwn.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_rtwn.c,v 1.12 2017/05/18 01:32:46 nonaka Exp $ */
+/* $NetBSD: if_rtwn.c,v 1.13 2017/10/23 09:31:18 msaitoh Exp $ */
/* $OpenBSD: if_rtwn.c,v 1.5 2015/06/14 08:02:47 stsp Exp $ */
#define IEEE80211_NO_HT
/*-
@@ -23,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_rtwn.c,v 1.12 2017/05/18 01:32:46 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_rtwn.c,v 1.13 2017/10/23 09:31:18 msaitoh Exp $");
#include <sys/param.h>
#include <sys/sockio.h>
@@ -357,7 +357,13 @@ rtwn_attach(device_t parent, device_t self, void *aux)
IFQ_SET_READY(&ifp->if_snd);
memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
- if_initialize(ifp);
+ error = if_initialize(ifp);
+ if (error != 0) {
+ ifp->if_softc = NULL; /* For rtwn_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);
@@ -389,6 +395,9 @@ rtwn_attach(device_t parent, device_t self, void *aux)
if (!pmf_device_register(self, NULL, NULL))
aprint_error_dev(self, "couldn't establish power handler\n");
+
+fail:
+ rtwn_detach(self, 0);
}
static int
@@ -407,6 +416,7 @@ rtwn_detach(device_t self, int flags)
if (ifp->if_softc != NULL) {
rtwn_stop(ifp, 0);
+ pmf_device_deregister(self);
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
bpf_detach(ifp);
ieee80211_ifdetach(ic);
@@ -433,8 +443,6 @@ rtwn_detach(device_t self, int flags)
pci_intr_release(sc->sc_pc, sc->sc_pihp, 1);
}
- pmf_device_deregister(self);
-
return 0;
}
diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c
index a7b16c9a6b6..018e23f4e00 100644
--- a/sys/dev/pci/if_wpi.c
+++ b/sys/dev/pci/if_wpi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wpi.c,v 1.78 2017/05/23 02:19:14 ozaki-r Exp $ */
+/* $NetBSD: if_wpi.c,v 1.79 2017/10/23 09:31:18 msaitoh Exp $ */
/*-
* Copyright (c) 2006, 2007
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.78 2017/05/23 02:19:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.79 2017/10/23 09:31:18 msaitoh Exp $");
/*
* Driver for Intel PRO/Wireless 3945ABG 802.11 network adapters.
@@ -366,7 +366,12 @@ wpi_attach(device_t parent __unused, device_t self, void *aux)
IFQ_SET_READY(&ifp->if_snd);
memcpy(ifp->if_xname, device_xname(self), IFNAMSIZ);
- if_initialize(ifp);
+ error = if_initialize(ifp);
+ if (error != 0) {
+ aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n",
+ error);
+ goto fail5;
+ }
ieee80211_ifattach(ic);
/* Use common softint-based if_input */
ifp->if_percpuq = if_percpuq_create(ifp);
@@ -409,6 +414,7 @@ wpi_attach(device_t parent __unused, device_t self, void *aux)
return;
/* free allocated memory if something failed during attachment */
+fail5: wpi_free_rx_ring(sc, &sc->rxq);
fail4: wpi_free_tx_ring(sc, &sc->cmdq);
fail3: while (--ac >= 0)
wpi_free_tx_ring(sc, &sc->txq[ac]);
diff --git a/sys/dev/pci/ixgbe/ixgbe.c b/sys/dev/pci/ixgbe/ixgbe.c
index ff8297bf108..50c4efece11 100644
--- a/sys/dev/pci/ixgbe/ixgbe.c
+++ b/sys/dev/pci/ixgbe/ixgbe.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.105 2017/10/18 10:43:32 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.106 2017/10/23 09:31:18 msaitoh Exp $ */
/******************************************************************************
@@ -1193,6 +1193,7 @@ ixgbe_setup_interface(device_t dev, struct adapter *adapter)
{
struct ethercom *ec = &adapter->osdep.ec;
struct ifnet *ifp;
+ int rv;
INIT_DEBUGOUT("ixgbe_setup_interface: begin");
@@ -1227,7 +1228,11 @@ ixgbe_setup_interface(device_t dev, struct adapter *adapter)
IFQ_SET_MAXLEN(&ifp->if_snd, adapter->num_tx_desc - 2);
IFQ_SET_READY(&ifp->if_snd);
- if_initialize(ifp);
+ rv = if_initialize(ifp);
+ if (rv != 0) {
+ aprint_error_dev(dev, "if_initialize failed(%d)\n", rv);
+ return rv;
+ }
adapter->ipq = if_percpuq_create(&adapter->osdep.ec.ec_if);
ether_ifattach(ifp, adapter->hw.mac.addr);
/*
diff --git a/sys/dev/pci/ixgbe/ixv.c b/sys/dev/pci/ixgbe/ixv.c
index 63f188063cb..ef128a0d2a0 100644
--- a/sys/dev/pci/ixgbe/ixv.c
+++ b/sys/dev/pci/ixgbe/ixv.c
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.72 2017/10/18 10:43:32 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.73 2017/10/23 09:31:18 msaitoh Exp $*/
/******************************************************************************
@@ -102,7 +102,7 @@ static int ixv_configure_interrupts(struct adapter *);
static void ixv_free_pci_resources(struct adapter *);
static void ixv_local_timer(void *);
static void ixv_local_timer_locked(void *);
-static void ixv_setup_interface(device_t, struct adapter *);
+static int ixv_setup_interface(device_t, struct adapter *);
static int ixv_negotiate_api(struct adapter *);
static void ixv_initialize_transmit_units(struct adapter *);
@@ -497,7 +497,11 @@ ixv_attach(device_t parent, device_t dev, void *aux)
adapter->enable_aim = ixv_enable_aim;
/* Setup OS specific network interface */
- ixv_setup_interface(dev, adapter);
+ error = ixv_setup_interface(dev, adapter);
+ if (error != 0) {
+ aprint_error_dev(dev, "ixv_setup_interface() failed!\n");
+ goto err_late;
+ }
error = ixv_allocate_msix(adapter, pa);
if (error) {
@@ -1370,11 +1374,12 @@ ixv_free_pci_resources(struct adapter * adapter)
*
* Setup networking device structure and register an interface.
************************************************************************/
-static void
+static int
ixv_setup_interface(device_t dev, struct adapter *adapter)
{
struct ethercom *ec = &adapter->osdep.ec;
struct ifnet *ifp;
+ int rv;
INIT_DEBUGOUT("ixv_setup_interface: begin");
@@ -1403,7 +1408,11 @@ ixv_setup_interface(device_t dev, struct adapter *adapter)
IFQ_SET_MAXLEN(&ifp->if_snd, adapter->num_tx_desc - 2);
IFQ_SET_READY(&ifp->if_snd);
- if_initialize(ifp);
+ rv = if_initialize(ifp);
+ if (rv != 0) {
+ aprint_error_dev(dev, "if_initialize failed(%d)\n", rv);
+ return rv;
+ }
adapter->ipq = if_percpuq_create(&adapter->osdep.ec.ec_if);
ether_ifattach(ifp, adapter->hw.mac.addr);
/*
@@ -1449,7 +1458,7 @@ ixv_setup_interface(device_t dev, struct adapter *adapter)
ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL);
ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO);
- return;
+ return 0;
} /* ixv_setup_interface */
diff --git a/sys/dev/scsipi/if_se.c b/sys/dev/scsipi/if_se.c
index b9847c3fe46..0d7a27ee9d4 100644
--- a/sys/dev/scsipi/if_se.c
+++ b/sys/dev/scsipi/if_se.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_se.c,v 1.94 2016/12/15 09:28:06 ozaki-r Exp $ */
+/* $NetBSD: if_se.c,v 1.95 2017/10/23 09:31:18 msaitoh Exp $ */
/*
* Copyright (c) 1997 Ian W. Dall <ian.dall@dsto.defence.gov.au>
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.94 2016/12/15 09:28:06 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.95 2017/10/23 09:31:18 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -314,6 +314,7 @@ seattach(device_t parent, device_t self, void *aux)
struct scsipi_periph *periph = sa->sa_periph;
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
u_int8_t myaddr[ETHER_ADDR_LEN];
+ int rv;
sc->sc_dev = self;
@@ -363,7 +364,13 @@ seattach(device_t parent, device_t self, void *aux)
IFQ_SET_READY(&ifp->if_snd);
/* Attach the interface. */
- if_initialize(ifp);
+ rv = if_initialize(ifp);
+ if (rv != 0) {
+ free(sc->sc_tbuf, M_DEVBUF);
+ callout_destroy(&sc->sc_ifstart_ch);
+ callout_destroy(&sc->sc_recv_ch);
+ return; /* Error */
+ }
ether_ifattach(ifp, myaddr);
if_register(ifp);
}