Author: hselasky
Date: Fri Feb  8 21:15:47 2013
New Revision: 246565
URL: http://svnweb.freebsd.org/changeset/base/246565

Log:
  Fix regression issue after r244503:
  Correct init order to fix a NULL pointer access.
  
  MFC after:    1 week
  Reported by:  Ian FREISLICH

Modified:
  head/sys/dev/usb/wlan/if_uath.c
  head/sys/dev/usb/wlan/if_upgt.c

Modified: head/sys/dev/usb/wlan/if_uath.c
==============================================================================
--- head/sys/dev/usb/wlan/if_uath.c     Fri Feb  8 21:09:44 2013        
(r246564)
+++ head/sys/dev/usb/wlan/if_uath.c     Fri Feb  8 21:15:47 2013        
(r246565)
@@ -358,22 +358,12 @@ uath_attach(device_t dev)
        callout_init(&sc->stat_ch, 0);
        callout_init_mtx(&sc->watchdog_ch, &sc->sc_mtx, 0);
 
-       /*
-        * Allocate xfers for firmware commands.
-        */
-       error = uath_alloc_cmd_list(sc, sc->sc_cmd);
-       if (error != 0) {
-               device_printf(sc->sc_dev,
-                   "could not allocate Tx command list\n");
-               goto fail;
-       }
-
        error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_xfer,
            uath_usbconfig, UATH_N_XFERS, sc, &sc->sc_mtx);
        if (error) {
                device_printf(dev, "could not allocate USB transfers, "
                    "err=%s\n", usbd_errstr(error));
-               goto fail1;
+               goto fail;
        }
 
        sc->sc_cmd_dma_buf = 
@@ -382,6 +372,16 @@ uath_attach(device_t dev)
            usbd_xfer_get_frame_buffer(sc->sc_xfer[UATH_BULK_TX], 0);
 
        /*
+        * Setup buffers for firmware commands.
+        */
+       error = uath_alloc_cmd_list(sc, sc->sc_cmd);
+       if (error != 0) {
+               device_printf(sc->sc_dev,
+                   "could not allocate Tx command list\n");
+               goto fail1;
+       }
+
+       /*
         * We're now ready to send+receive firmware commands.
         */
        UATH_LOCK(sc);
@@ -492,8 +492,8 @@ uath_attach(device_t dev)
 
 fail4: if_free(ifp);
 fail3: UATH_UNLOCK(sc);
-fail2: usbd_transfer_unsetup(sc->sc_xfer, UATH_N_XFERS);
-fail1: uath_free_cmd_list(sc, sc->sc_cmd);
+fail2: uath_free_cmd_list(sc, sc->sc_cmd);
+fail1: usbd_transfer_unsetup(sc->sc_xfer, UATH_N_XFERS);
 fail:
        return (error);
 }

Modified: head/sys/dev/usb/wlan/if_upgt.c
==============================================================================
--- head/sys/dev/usb/wlan/if_upgt.c     Fri Feb  8 21:09:44 2013        
(r246564)
+++ head/sys/dev/usb/wlan/if_upgt.c     Fri Feb  8 21:15:47 2013        
(r246565)
@@ -259,20 +259,12 @@ upgt_attach(device_t dev)
        callout_init(&sc->sc_led_ch, 0);
        callout_init(&sc->sc_watchdog_ch, 0);
 
-       /* Allocate TX and RX xfers.  */
-       error = upgt_alloc_tx(sc);
-       if (error)
-               goto fail1;
-       error = upgt_alloc_rx(sc);
-       if (error)
-               goto fail2;
-
        error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_xfer,
            upgt_config, UPGT_N_XFERS, sc, &sc->sc_mtx);
        if (error) {
                device_printf(dev, "could not allocate USB transfers, "
                    "err=%s\n", usbd_errstr(error));
-               goto fail3;
+               goto fail1;
        }
 
        sc->sc_rx_dma_buf = usbd_xfer_get_frame_buffer(
@@ -280,6 +272,14 @@ upgt_attach(device_t dev)
        sc->sc_tx_dma_buf = usbd_xfer_get_frame_buffer(
            sc->sc_xfer[UPGT_BULK_TX], 0);
 
+       /* Setup TX and RX buffers */
+       error = upgt_alloc_tx(sc);
+       if (error)
+               goto fail2;
+       error = upgt_alloc_rx(sc);
+       if (error)
+               goto fail3;
+
        ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
        if (ifp == NULL) {
                device_printf(dev, "can not if_alloc()\n");
@@ -382,9 +382,9 @@ upgt_attach(device_t dev)
        return (0);
 
 fail5: if_free(ifp);
-fail4: usbd_transfer_unsetup(sc->sc_xfer, UPGT_N_XFERS);
-fail3: upgt_free_rx(sc);
-fail2: upgt_free_tx(sc);
+fail4: upgt_free_rx(sc);
+fail3: upgt_free_tx(sc);
+fail2: usbd_transfer_unsetup(sc->sc_xfer, UPGT_N_XFERS);
 fail1: mtx_destroy(&sc->sc_mtx);
 
        return (error);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to