aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorBob Copeland <me@bobcopeland.com>2011-08-07 19:36:07 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-08-09 16:11:33 -0400
commitbdc71bc59231f5542af13b5061b9ab124d093050 (patch)
treef67004e74a4a566c27ee5eb801a4c86b3f58ab1b /drivers/net/wireless
parent276b02e2a0ada2e0196852c312560ffdabcebddc (diff)
ath5k: fix error handling in ath5k_beacon_send
This cleans up error handling for the beacon in case of dma mapping failure. We need to free the skb when dma mapping fails instead of nulling and leaking the pointer, and we should bail out to avoid giving the hardware the bad descriptor. Finally, we need to perform the null check after trying to update the beacon, or else beacons will never be sent after a single mapping failure. Cc: stable@kernel.org Signed-off-by: Bob Copeland <me@bobcopeland.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index f54dff44ed50..c3119a6caace 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -1735,6 +1735,8 @@ ath5k_beacon_setup(struct ath5k_hw *ah, struct ath5k_buf *bf)
1735 1735
1736 if (dma_mapping_error(ah->dev, bf->skbaddr)) { 1736 if (dma_mapping_error(ah->dev, bf->skbaddr)) {
1737 ATH5K_ERR(ah, "beacon DMA mapping failed\n"); 1737 ATH5K_ERR(ah, "beacon DMA mapping failed\n");
1738 dev_kfree_skb_any(skb);
1739 bf->skb = NULL;
1738 return -EIO; 1740 return -EIO;
1739 } 1741 }
1740 1742
@@ -1819,8 +1821,6 @@ ath5k_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1819 ath5k_txbuf_free_skb(ah, avf->bbuf); 1821 ath5k_txbuf_free_skb(ah, avf->bbuf);
1820 avf->bbuf->skb = skb; 1822 avf->bbuf->skb = skb;
1821 ret = ath5k_beacon_setup(ah, avf->bbuf); 1823 ret = ath5k_beacon_setup(ah, avf->bbuf);
1822 if (ret)
1823 avf->bbuf->skb = NULL;
1824out: 1824out:
1825 return ret; 1825 return ret;
1826} 1826}
@@ -1840,6 +1840,7 @@ ath5k_beacon_send(struct ath5k_hw *ah)
1840 struct ath5k_vif *avf; 1840 struct ath5k_vif *avf;
1841 struct ath5k_buf *bf; 1841 struct ath5k_buf *bf;
1842 struct sk_buff *skb; 1842 struct sk_buff *skb;
1843 int err;
1843 1844
1844 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON, "in beacon_send\n"); 1845 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON, "in beacon_send\n");
1845 1846
@@ -1888,11 +1889,6 @@ ath5k_beacon_send(struct ath5k_hw *ah)
1888 1889
1889 avf = (void *)vif->drv_priv; 1890 avf = (void *)vif->drv_priv;
1890 bf = avf->bbuf; 1891 bf = avf->bbuf;
1891 if (unlikely(bf->skb == NULL || ah->opmode == NL80211_IFTYPE_STATION ||
1892 ah->opmode == NL80211_IFTYPE_MONITOR)) {
1893 ATH5K_WARN(ah, "bf=%p bf_skb=%p\n", bf, bf ? bf->skb : NULL);
1894 return;
1895 }
1896 1892
1897 /* 1893 /*
1898 * Stop any current dma and put the new frame on the queue. 1894 * Stop any current dma and put the new frame on the queue.
@@ -1906,8 +1902,17 @@ ath5k_beacon_send(struct ath5k_hw *ah)
1906 1902
1907 /* refresh the beacon for AP or MESH mode */ 1903 /* refresh the beacon for AP or MESH mode */
1908 if (ah->opmode == NL80211_IFTYPE_AP || 1904 if (ah->opmode == NL80211_IFTYPE_AP ||
1909 ah->opmode == NL80211_IFTYPE_MESH_POINT) 1905 ah->opmode == NL80211_IFTYPE_MESH_POINT) {
1910 ath5k_beacon_update(ah->hw, vif); 1906 err = ath5k_beacon_update(ah->hw, vif);
1907 if (err)
1908 return;
1909 }
1910
1911 if (unlikely(bf->skb == NULL || ah->opmode == NL80211_IFTYPE_STATION ||
1912 ah->opmode == NL80211_IFTYPE_MONITOR)) {
1913 ATH5K_WARN(ah, "bf=%p bf_skb=%p\n", bf, bf->skb);
1914 return;
1915 }
1911 1916
1912 trace_ath5k_tx(ah, bf->skb, &ah->txqs[ah->bhalq]); 1917 trace_ath5k_tx(ah, bf->skb, &ah->txqs[ah->bhalq]);
1913 1918