diff options
-rw-r--r-- | sys/dev/ic/rtwn.c | 8 | ||||
-rw-r--r-- | sys/dev/ic/rtwnvar.h | 4 | ||||
-rw-r--r-- | sys/dev/pci/if_rtwn.c | 11 |
3 files changed, 16 insertions, 7 deletions
diff --git a/sys/dev/ic/rtwn.c b/sys/dev/ic/rtwn.c index 0753126368b..e5a83a80c88 100644 --- a/sys/dev/ic/rtwn.c +++ b/sys/dev/ic/rtwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtwn.c,v 1.2 2016/03/09 20:35:08 stsp Exp $ */ +/* $OpenBSD: rtwn.c,v 1.3 2016/03/09 20:36:16 stsp Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> @@ -152,7 +152,7 @@ void rtwn_stop(struct ifnet *); #define rtwn_bb_write rtwn_write_4 #define rtwn_bb_read rtwn_read_4 -void +int rtwn_attach(struct device *pdev, struct rtwn_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; @@ -169,7 +169,7 @@ rtwn_attach(struct device *pdev, struct rtwn_softc *sc) error = rtwn_read_chipid(sc); if (error != 0) { printf("%s: unsupported test chip\n", sc->sc_pdev->dv_xname); - return; + return (ENXIO); } /* Determine number of Tx/Rx chains. */ @@ -250,6 +250,8 @@ rtwn_attach(struct device *pdev, struct rtwn_softc *sc) sc->sc_newstate = ic->ic_newstate; ic->ic_newstate = rtwn_newstate; ieee80211_media_init(ifp, rtwn_media_change, ieee80211_media_status); + + return (0); } int diff --git a/sys/dev/ic/rtwnvar.h b/sys/dev/ic/rtwnvar.h index 07b8e1c04f5..c17e4e2998a 100644 --- a/sys/dev/ic/rtwnvar.h +++ b/sys/dev/ic/rtwnvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rtwnvar.h,v 1.1 2016/03/09 18:18:28 stsp Exp $ */ +/* $OpenBSD: rtwnvar.h,v 1.2 2016/03/09 20:36:16 stsp Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> @@ -76,7 +76,7 @@ struct rtwn_softc { uint32_t rf_chnlbw[R92C_MAX_CHAINS]; }; -void rtwn_attach(struct device *, struct rtwn_softc *); +int rtwn_attach(struct device *, struct rtwn_softc *); int rtwn_detach(struct rtwn_softc *, int); int rtwn_activate(struct rtwn_softc *, int); int8_t rtwn_get_rssi(struct rtwn_softc *, int, void *); diff --git a/sys/dev/pci/if_rtwn.c b/sys/dev/pci/if_rtwn.c index fa84bbcbb70..d1fac937eab 100644 --- a/sys/dev/pci/if_rtwn.c +++ b/sys/dev/pci/if_rtwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_rtwn.c,v 1.16 2016/03/09 18:18:28 stsp Exp $ */ +/* $OpenBSD: if_rtwn.c,v 1.17 2016/03/09 20:36:16 stsp Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> @@ -305,6 +305,7 @@ rtwn_pci_attach(struct device *parent, struct device *self, void *aux) if (error != 0) { printf("%s: could not allocate Tx buffers\n", sc->sc_dev.dv_xname); + rtwn_free_rx_list(sc); return; } } @@ -324,7 +325,13 @@ rtwn_pci_attach(struct device *parent, struct device *self, void *aux) sc->sc_sc.sc_ops.disable_intr = rtwn_disable_intr; sc->sc_sc.sc_ops.stop = rtwn_pci_stop; sc->sc_sc.sc_ops.is_oactive = rtwn_is_oactive; - rtwn_attach(&sc->sc_dev, &sc->sc_sc); + error = rtwn_attach(&sc->sc_dev, &sc->sc_sc); + if (error != 0) { + rtwn_free_rx_list(sc); + for (i = 0; i < RTWN_NTXQUEUES; i++) + rtwn_free_tx_list(sc, i); + return; + } /* ifp is now valid */ ifp = &sc->sc_sc.sc_ic.ic_if; |