summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2013-02-08 21:15:47 +0000
committerhselasky <hselasky@FreeBSD.org>2013-02-08 21:15:47 +0000
commit6a11631ce88052548f4dca6d78cafcac473757ca (patch)
tree7b7783b99ff5976146ae2c097a46fbebc85fb20a
parentc03e3032d5b1c0469a386da4410584ebdaa8188a (diff)
downloadFreeBSD-src-6a11631ce88052548f4dca6d78cafcac473757ca.zip
FreeBSD-src-6a11631ce88052548f4dca6d78cafcac473757ca.tar.gz
Fix regression issue after r244503:
Correct init order to fix a NULL pointer access. MFC after: 1 week Reported by: Ian FREISLICH
-rw-r--r--sys/dev/usb/wlan/if_uath.c26
-rw-r--r--sys/dev/usb/wlan/if_upgt.c24
2 files changed, 25 insertions, 25 deletions
diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c
index 0ac57af..37162c0 100644
--- a/sys/dev/usb/wlan/if_uath.c
+++ b/sys/dev/usb/wlan/if_uath.c
@@ -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);
}
diff --git a/sys/dev/usb/wlan/if_upgt.c b/sys/dev/usb/wlan/if_upgt.c
index c625926..6b49df1 100644
--- a/sys/dev/usb/wlan/if_upgt.c
+++ b/sys/dev/usb/wlan/if_upgt.c
@@ -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);
OpenPOWER on IntegriCloud