Module Name:    src
Committed By:   msaitoh
Date:           Mon Oct 23 09:28:38 UTC 2017

Modified Files:
        src/sys/dev/pci: if_iwm.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/pci/if_iwm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_iwm.c
diff -u src/sys/dev/pci/if_iwm.c:1.75 src/sys/dev/pci/if_iwm.c:1.76
--- src/sys/dev/pci/if_iwm.c:1.75	Sun Jul 23 10:55:00 2017
+++ src/sys/dev/pci/if_iwm.c	Mon Oct 23 09:28:38 2017
@@ -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 sel
 	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 sel
 	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 sel
 
 	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);

Reply via email to