aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorBen Greear <greearb@candelatech.com>2010-10-14 15:45:30 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-10-15 15:57:42 -0400
commit6cf9e995f91e5bbffb2bef85feef490e5b67605d (patch)
tree11d458a9a447fadb4b85a90664d327055f67b66f /drivers/net/wireless
parentc1739eb3e61e160f124bc842c219011916f63068 (diff)
ath9k: Null out references to stale pointers.
This doesn't fix any problem that I'm aware of, but should make it harder to add use-after-free type bugs in the future. Signed-off-by: Ben Greear <greearb@candelatech.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/ath/ath9k/beacon.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c6
3 files changed, 16 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index af8fedda001b..4ed010d4ef96 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -139,6 +139,7 @@ static struct ath_buf *ath_beacon_generate(struct ieee80211_hw *hw,
139 dma_unmap_single(sc->dev, bf->bf_buf_addr, 139 dma_unmap_single(sc->dev, bf->bf_buf_addr,
140 skb->len, DMA_TO_DEVICE); 140 skb->len, DMA_TO_DEVICE);
141 dev_kfree_skb_any(skb); 141 dev_kfree_skb_any(skb);
142 bf->bf_buf_addr = 0;
142 } 143 }
143 144
144 /* Get a new beacon from mac80211 */ 145 /* Get a new beacon from mac80211 */
@@ -167,6 +168,7 @@ static struct ath_buf *ath_beacon_generate(struct ieee80211_hw *hw,
167 if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) { 168 if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
168 dev_kfree_skb_any(skb); 169 dev_kfree_skb_any(skb);
169 bf->bf_mpdu = NULL; 170 bf->bf_mpdu = NULL;
171 bf->bf_buf_addr = 0;
170 ath_print(common, ATH_DBG_FATAL, 172 ath_print(common, ATH_DBG_FATAL,
171 "dma_mapping_error on beaconing\n"); 173 "dma_mapping_error on beaconing\n");
172 return NULL; 174 return NULL;
@@ -255,6 +257,7 @@ int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif)
255 skb->len, DMA_TO_DEVICE); 257 skb->len, DMA_TO_DEVICE);
256 dev_kfree_skb_any(skb); 258 dev_kfree_skb_any(skb);
257 bf->bf_mpdu = NULL; 259 bf->bf_mpdu = NULL;
260 bf->bf_buf_addr = 0;
258 } 261 }
259 262
260 /* NB: the beacon data buffer must be 32-bit aligned. */ 263 /* NB: the beacon data buffer must be 32-bit aligned. */
@@ -300,6 +303,7 @@ int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif)
300 if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) { 303 if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
301 dev_kfree_skb_any(skb); 304 dev_kfree_skb_any(skb);
302 bf->bf_mpdu = NULL; 305 bf->bf_mpdu = NULL;
306 bf->bf_buf_addr = 0;
303 ath_print(common, ATH_DBG_FATAL, 307 ath_print(common, ATH_DBG_FATAL,
304 "dma_mapping_error on beacon alloc\n"); 308 "dma_mapping_error on beacon alloc\n");
305 return -ENOMEM; 309 return -ENOMEM;
@@ -326,6 +330,7 @@ void ath_beacon_return(struct ath_softc *sc, struct ath_vif *avp)
326 skb->len, DMA_TO_DEVICE); 330 skb->len, DMA_TO_DEVICE);
327 dev_kfree_skb_any(skb); 331 dev_kfree_skb_any(skb);
328 bf->bf_mpdu = NULL; 332 bf->bf_mpdu = NULL;
333 bf->bf_buf_addr = 0;
329 } 334 }
330 list_add_tail(&bf->list, &sc->beacon.bbuf); 335 list_add_tail(&bf->list, &sc->beacon.bbuf);
331 336
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 2e427522672d..fe73fc50082a 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -268,6 +268,7 @@ static int ath_rx_edma_init(struct ath_softc *sc, int nbufs)
268 bf->bf_buf_addr))) { 268 bf->bf_buf_addr))) {
269 dev_kfree_skb_any(skb); 269 dev_kfree_skb_any(skb);
270 bf->bf_mpdu = NULL; 270 bf->bf_mpdu = NULL;
271 bf->bf_buf_addr = 0;
271 ath_print(common, ATH_DBG_FATAL, 272 ath_print(common, ATH_DBG_FATAL,
272 "dma_mapping_error() on RX init\n"); 273 "dma_mapping_error() on RX init\n");
273 error = -ENOMEM; 274 error = -ENOMEM;
@@ -358,6 +359,7 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
358 bf->bf_buf_addr))) { 359 bf->bf_buf_addr))) {
359 dev_kfree_skb_any(skb); 360 dev_kfree_skb_any(skb);
360 bf->bf_mpdu = NULL; 361 bf->bf_mpdu = NULL;
362 bf->bf_buf_addr = 0;
361 ath_print(common, ATH_DBG_FATAL, 363 ath_print(common, ATH_DBG_FATAL,
362 "dma_mapping_error() on RX init\n"); 364 "dma_mapping_error() on RX init\n");
363 error = -ENOMEM; 365 error = -ENOMEM;
@@ -392,6 +394,8 @@ void ath_rx_cleanup(struct ath_softc *sc)
392 common->rx_bufsize, 394 common->rx_bufsize,
393 DMA_FROM_DEVICE); 395 DMA_FROM_DEVICE);
394 dev_kfree_skb(skb); 396 dev_kfree_skb(skb);
397 bf->bf_buf_addr = 0;
398 bf->bf_mpdu = NULL;
395 } 399 }
396 } 400 }
397 401
@@ -1733,6 +1737,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1733 bf->bf_buf_addr))) { 1737 bf->bf_buf_addr))) {
1734 dev_kfree_skb_any(requeue_skb); 1738 dev_kfree_skb_any(requeue_skb);
1735 bf->bf_mpdu = NULL; 1739 bf->bf_mpdu = NULL;
1740 bf->bf_buf_addr = 0;
1736 ath_print(common, ATH_DBG_FATAL, 1741 ath_print(common, ATH_DBG_FATAL,
1737 "dma_mapping_error() on RX\n"); 1742 "dma_mapping_error() on RX\n");
1738 ath_rx_send_to_mac80211(hw, sc, skb, rxs); 1743 ath_rx_send_to_mac80211(hw, sc, skb, rxs);
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index b053058ae5ea..d077186da870 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1643,6 +1643,7 @@ static int ath_tx_setup_buffer(struct ieee80211_hw *hw, struct ath_buf *bf,
1643 skb->len, DMA_TO_DEVICE); 1643 skb->len, DMA_TO_DEVICE);
1644 if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) { 1644 if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
1645 bf->bf_mpdu = NULL; 1645 bf->bf_mpdu = NULL;
1646 bf->bf_buf_addr = 0;
1646 ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL, 1647 ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL,
1647 "dma_mapping_error() on TX\n"); 1648 "dma_mapping_error() on TX\n");
1648 return -ENOMEM; 1649 return -ENOMEM;
@@ -1912,6 +1913,7 @@ static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
1912 } 1913 }
1913 1914
1914 dma_unmap_single(sc->dev, bf->bf_buf_addr, skb->len, DMA_TO_DEVICE); 1915 dma_unmap_single(sc->dev, bf->bf_buf_addr, skb->len, DMA_TO_DEVICE);
1916 bf->bf_buf_addr = 0;
1915 1917
1916 if (bf->bf_state.bfs_paprd) { 1918 if (bf->bf_state.bfs_paprd) {
1917 if (time_after(jiffies, 1919 if (time_after(jiffies,
@@ -1924,6 +1926,10 @@ static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
1924 ath_debug_stat_tx(sc, txq, bf, ts); 1926 ath_debug_stat_tx(sc, txq, bf, ts);
1925 ath_tx_complete(sc, skb, bf->aphy, tx_flags); 1927 ath_tx_complete(sc, skb, bf->aphy, tx_flags);
1926 } 1928 }
1929 /* At this point, skb (bf->bf_mpdu) is consumed...make sure we don't
1930 * accidentally reference it later.
1931 */
1932 bf->bf_mpdu = NULL;
1927 1933
1928 /* 1934 /*
1929 * Return the list of ath_buf of this mpdu to free queue 1935 * Return the list of ath_buf of this mpdu to free queue