ath5k: fix potential NULL pointer dereference in ath5k_beacon_update()
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>
Mon, 8 Oct 2012 00:42:58 +0000 (08:42 +0800)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 8 Oct 2012 19:06:04 +0000 (15:06 -0400)
The dereference should be moved below the NULL test.

dpatch engine is used to auto generate this patch.
(https://github.com/weiyj/dpatch)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath5k/base.c

index 9fd6d9a..9f31cfa 100644 (file)
@@ -1804,7 +1804,7 @@ ath5k_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
        int ret;
        struct ath5k_hw *ah = hw->priv;
-       struct ath5k_vif *avf = (void *)vif->drv_priv;
+       struct ath5k_vif *avf;
        struct sk_buff *skb;
 
        if (WARN_ON(!vif)) {
@@ -1819,6 +1819,7 @@ ath5k_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
                goto out;
        }
 
+       avf = (void *)vif->drv_priv;
        ath5k_txbuf_free_skb(ah, avf->bbuf);
        avf->bbuf->skb = skb;
        ret = ath5k_beacon_setup(ah, avf->bbuf);