diff options
| author | msaitoh <msaitoh@NetBSD.org> | 2017-10-23 09:28:38 +0000 |
|---|---|---|
| committer | msaitoh <msaitoh@NetBSD.org> | 2017-10-23 09:28:38 +0000 |
| commit | 766faa964e36ca6d493d4da0f589620950c3db2d (patch) | |
| tree | 753064ba7730f1db883e57552c887eee77f27571 /sys/dev | |
| parent | 6033e52af4c165ebe1e6411daa4589c49ab9f628 (diff) | |
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/pci/if_iwm.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c index 236da6dccf7..e9383f30d6b 100644 --- a/sys/dev/pci/if_iwm.c +++ b/sys/dev/pci/if_iwm.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_iwm.c,v 1.75 2017/07/23 10:55:00 para Exp $ */ +/* $NetBSD: if_iwm.c,v 1.76 2017/10/23 09:28:38 msaitoh Exp $ */ /* OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp */ #define IEEE80211_NO_HT /* @@ -106,7 +106,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.75 2017/07/23 10:55:00 para Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.76 2017/10/23 09:28:38 msaitoh Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -8037,7 +8037,7 @@ iwm_attach(device_t parent, device_t self, void *aux) err = iwm_alloc_rx_ring(sc, &sc->rxq); if (err) { aprint_error_dev(sc->sc_dev, "could not allocate RX ring\n"); - goto fail4; + goto fail5; } /* Clear pending interrupts. */ @@ -8122,7 +8122,12 @@ iwm_attach(device_t parent, device_t self, void *aux) IFQ_SET_READY(&ifp->if_snd); memcpy(ifp->if_xname, DEVNAME(sc), IFNAMSIZ); - if_initialize(ifp); + err = if_initialize(ifp); + if (err != 0) { + aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", + err); + goto fail6; + } #if 0 ieee80211_ifattach(ic); #else @@ -8168,10 +8173,10 @@ iwm_attach(device_t parent, device_t self, void *aux) return; -fail4: while (--txq_i >= 0) +fail6: iwm_free_rx_ring(sc, &sc->rxq); +fail5: while (--txq_i >= 0) iwm_free_tx_ring(sc, &sc->txq[txq_i]); - iwm_free_rx_ring(sc, &sc->rxq); - iwm_dma_contig_free(&sc->sched_dma); +fail4: iwm_dma_contig_free(&sc->sched_dma); fail3: if (sc->ict_dma.vaddr != NULL) iwm_dma_contig_free(&sc->ict_dma); fail2: iwm_dma_contig_free(&sc->kw_dma); |
