fa.openbsd.tech
[Top] [All Lists]

acx diff needs testing

Subject: acx diff needs testing
From: Stefan Sperling
Date: Mon, 09 Mar 2009 11:55:30 UTC
Newsgroups: fa.openbsd.tech

acx(4) ignores return values in many places.
This diff plugs some of these.

Please test with both pci and cardbus versions to make sure
there are no regressions. This diff should not affect normal
operation in any way.

Please don't forget to test scanning for networks while testing.

Thanks,
Stefan

Index: dev/cardbus/if_acx_cardbus.c
===================================================================
RCS file: /cvs/src/sys/dev/cardbus/if_acx_cardbus.c,v
retrieving revision 1.12
diff -u -p -r1.12 if_acx_cardbus.c
--- dev/cardbus/if_acx_cardbus.c        26 Feb 2009 23:03:05 -0000      1.12
+++ dev/cardbus/if_acx_cardbus.c        9 Mar 2009 11:38:13 -0000
@@ -220,13 +220,18 @@ acx_cardbus_detach(struct device *self, 
 int
 acx_cardbus_enable(struct acx_softc *sc)
 {
-       struct acx_cardbus_softc *csc = (struct acx_cardbus_softc *)sc;
+       struct acx_cardbus_softc *csc;
+       int error;
+
+       csc = (struct acx_cardbus_softc *)sc;
        cardbus_devfunc_t ct = csc->sc_ct;
        cardbus_chipset_tag_t cc = ct->ct_cc;
        cardbus_function_tag_t cf = ct->ct_cf;
 
        /* power on the socket */
-       Cardbus_function_enable(ct);
+       error = Cardbus_function_enable(ct);
+       if (error)
+               return error;
 
        /* setup the PCI configuration registers */
        acx_cardbus_setup(csc);
Index: dev/ic/acx.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/acx.c,v
retrieving revision 1.90
diff -u -p -r1.90 acx.c
--- dev/ic/acx.c        9 Mar 2009 11:25:22 -0000       1.90
+++ dev/ic/acx.c        9 Mar 2009 11:38:13 -0000
@@ -164,7 +164,7 @@ void         acx_rxeof(struct acx_softc *);
 
 int     acx_dma_alloc(struct acx_softc *);
 void    acx_dma_free(struct acx_softc *);
-int     acx_init_tx_ring(struct acx_softc *);
+void    acx_init_tx_ring(struct acx_softc *);
 int     acx_init_rx_ring(struct acx_softc *);
 int     acx_newbuf(struct acx_softc *, struct acx_rxbuf *, int);
 int     acx_encap(struct acx_softc *, struct acx_txbuf *,
@@ -272,6 +272,8 @@ acx_attach(struct acx_softc *sc)
                uint8_t val;
 
                error = acx_read_eeprom(sc, i, &val);
+               if (error)
+                       return (error);
                if (i % 10 == 0)
                        printf("\n");
                printf("%02x ", val);
@@ -402,16 +404,14 @@ acx_init(struct ifnet *ifp)
                return (EIO);
 
        /* enable card if possible */
-       if (sc->sc_enable != NULL)
-               (*sc->sc_enable)(sc);
-
-       error = acx_init_tx_ring(sc);
-       if (error) {
-               printf("%s: can't initialize TX ring\n",
-                   sc->sc_dev.dv_xname);
-               goto back;
+       if (sc->sc_enable != NULL) {
+               error = (*sc->sc_enable)(sc);
+               if (error)
+                       return (EIO);
        }
 
+       acx_init_tx_ring(sc);
+
        error = acx_init_rx_ring(sc);
        if (error) {
                printf("%s: can't initialize RX ring\n",
@@ -486,12 +486,11 @@ acx_init(struct ifnet *ifp)
        else
                /* in monitor mode change directly into run state */
                ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
-
-back:
-       if (error)
-               acx_stop(sc);
-
+       
        return (0);
+back:
+       acx_stop(sc);
+       return (error);
 }
 
 void
@@ -858,10 +857,10 @@ acx_ioctl(struct ifnet *ifp, u_long cmd,
        case SIOCSIFFLAGS:
                if (ifp->if_flags & IFF_UP) {
                        if ((ifp->if_flags & IFF_RUNNING) == 0)
-                               acx_init(ifp);
+                               error = acx_init(ifp);
                } else {
                        if (ifp->if_flags & IFF_RUNNING)
-                               acx_stop(sc);
+                               error = acx_stop(sc);
                }
                break;
        case SIOCADDMULTI:
@@ -897,8 +896,9 @@ acx_ioctl(struct ifnet *ifp, u_long cmd,
        if (error == ENETRESET) {
                if ((ifp->if_flags & (IFF_RUNNING | IFF_UP)) ==
                    (IFF_RUNNING | IFF_UP))
-                       acx_init(ifp);
-               error = 0;
+                       error = acx_init(ifp);
+               else
+                       error = 0;
        }
 
        splx(s);
@@ -1739,7 +1739,10 @@ acx_newstate(struct ieee80211com *ic, en
                        uint8_t chan;
 
                        chan = ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan);
-                       (void)acx_set_channel(sc, chan);
+                       if (acx_set_channel(sc, chan) != 0) {
+                               error = 1;
+                               goto back;
+                       }
 
                        timeout_add(&sc->sc_chanscan_timer,
                            hz / acx_chanscan_rate);
@@ -2059,7 +2062,7 @@ acx_dma_free(struct acx_softc *sc)
                bus_dmamap_destroy(sc->sc_dmat, bd->mbuf_tmp_dmamap);
 }
 
-int
+void
 acx_init_tx_ring(struct acx_softc *sc)
 {
        struct acx_ring_data *rd;
@@ -2088,8 +2091,6 @@ acx_init_tx_ring(struct acx_softc *sc)
        bd->tx_free_start = 0;
        bd->tx_used_start = 0;
        bd->tx_used_count = 0;
-
-       return (0);
 }
 
 int
@@ -2441,8 +2442,7 @@ acx_beacon_locate(struct mbuf *m, u_int8
                if (frm[off] == type)
                        return (off);
        }
-       /* type not found */
-       return (m->m_len);
+       return (-1);
 }
 
 int
@@ -2462,6 +2462,10 @@ acx_set_beacon_tmplt(struct acx_softc *s
                return (1);
 
        off = acx_beacon_locate(m, IEEE80211_ELEMID_TIM);
+       if (off < 0) {
+               m_free(m);
+               return (1);
+       }
 
        m_copydata(m, 0, off, (caddr_t)&beacon.data);
        len = off + sizeof(beacon.size);


<Prev in Thread] Current Thread [Next in Thread>