diff options
author | bschmidt <bschmidt@FreeBSD.org> | 2011-04-16 11:11:22 +0000 |
---|---|---|
committer | bschmidt <bschmidt@FreeBSD.org> | 2011-04-16 11:11:22 +0000 |
commit | ad65a3b837e18b023a8a3ac595c5af99bf5dd214 (patch) | |
tree | 9ce8c02c3b21f96c6c2a0ae80c1de90ceb08db04 | |
parent | 7100785646725195f2be5d45e0293b4a9dd0fbf8 (diff) | |
download | FreeBSD-src-ad65a3b837e18b023a8a3ac595c5af99bf5dd214.zip FreeBSD-src-ad65a3b837e18b023a8a3ac595c5af99bf5dd214.tar.gz |
Prevent double-free, also use the same error codes as OpenBSD.
-rw-r--r-- | sys/dev/iwn/if_iwn.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index f25397b..89e7115 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -1294,7 +1294,7 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, struct iwn_rx_ring *ring) if (data->m == NULL) { device_printf(sc->sc_dev, "%s: could not allocate rx mbuf\n", __func__); - error = ENOMEM; + error = ENOBUFS; goto fail; } @@ -1305,8 +1305,6 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, struct iwn_rx_ring *ring) device_printf(sc->sc_dev, "%s: bus_dmamap_load failed, error %d\n", __func__, error); - m_freem(data->m); - error = ENOMEM; /* XXX unique code */ goto fail; } @@ -1361,6 +1359,7 @@ iwn_free_rx_ring(struct iwn_softc *sc, struct iwn_rx_ring *ring) BUS_DMASYNC_POSTREAD); bus_dmamap_unload(ring->data_dmat, data->map); m_freem(data->m); + data->m = NULL; } if (data->map != NULL) bus_dmamap_destroy(ring->data_dmat, data->map); |