Fix regression issue after r244503:

Correct init order to fix a NULL pointer access.

MFC after:	1 week
Reported by:	Ian FREISLICH
This commit is contained in:
Hans Petter Selasky 2013-02-08 21:15:47 +00:00
parent 4e1e0e2582
commit 2d8a425be0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=246565
2 changed files with 25 additions and 25 deletions

View File

@ -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 =
@ -381,6 +371,16 @@ uath_attach(device_t dev)
sc->sc_tx_dma_buf =
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.
*/
@ -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);
}

View File

@ -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);