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/c81b26a09afa
branches:  trunk
changeset: 357013:c81b26a09afa
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Oct 23 09:28:38 2017 +0000

description:
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.

diffstat:

 sys/dev/pci/if_iwm.c |  19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diffs (55 lines):

diff -r dac77e326826 -r c81b26a09afa sys/dev/pci/if_iwm.c
--- a/sys/dev/pci/if_iwm.c      Mon Oct 23 09:28:13 2017 +0000
+++ b/sys/dev/pci/if_iwm.c      Mon Oct 23 09:28:38 2017 +0000
@@ -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 @@
        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 @@
        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 @@
 
        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);



Home | Main Index | Thread Index | Old Index