Skip to contentSkip to conversation

d80211: Only free WEP crypto ciphers when they have been allocated correctly.

PATCH Applied Gertjan van Wingerde 3 participants 4 messages Jan 6, 2007 – Jan 10, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 d80211: Only free WEP crypto ciphers when they have been allocated correctly.

The d80211 stack still tries to free the WEP crypto ciphers, even when allocating them previously has failed. This results in an oops. Make sure that the d80211 stack only frees the crypto ciphers when they have been allocated successfully.

---

net/d80211/wep.c +0 -0
index dee8eae..5abcda6 100644
@@ -44,8 +44,10 @@ int ieee80211_wep_init(struct ieee80211_local *local)
 

void ieee80211_wep_free(struct ieee80211_local *local) {
- crypto_free_blkcipher(local->wep_tx_tfm);
- crypto_free_blkcipher(local->wep_rx_tfm);
+ if (!IS_ERR(local->wep_tx_tfm))
+ crypto_free_blkcipher(local->wep_tx_tfm);
+ if (!IS_ERR(local->wep_rx_tfm))
+ crypto_free_blkcipher(local->wep_rx_tfm);
}

static inline int ieee80211_wep_weak_iv(u32 iv, int keylen)

#1 lore raw
Quoted 2 lines · Gertjan van Wingerde

The d80211 stack still tries to free the WEP crypto ciphers, even when allocating them previously has failed.

Actually, the code might not even have tried to allocate them. The ciphers are guaranteed to be allocated when the device is registered however, so we should be able to free it safely on unregister.

---

 net/d80211/ieee80211.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/d80211/ieee80211.c +1 -1
index 6e10db5..926d160 100644
@@ -4715,6 +4715,7 @@ void ieee80211_unregister_hw(struct ieee
 	skb_queue_purge(&local->skb_queue_unreliable);
 
 	ieee80211_dev_free_index(local);
+	ieee80211_wep_free(local);
 	ieee80211_led_exit(local);
 }
 EXPORT_SYMBOL(ieee80211_unregister_hw);
@@ -4724,7 +4725,6 @@ void ieee80211_free_hw(struct ieee80211_
 	struct ieee80211_local *local = hw_to_local(hw);
 
 	ieee80211_if_free(local->mdev);
-	ieee80211_wep_free(local);
 	ieee80211_dev_free(local);
 }
 EXPORT_SYMBOL(ieee80211_free_hw);
author Acked-by
#2 lore raw
Quoted 26 lines · Michael Wu
Quoted 3 lines · Gertjan van Wingerde

The d80211 stack still tries to free the WEP crypto ciphers, even when allocating them previously has failed.

Actually, the code might not even have tried to allocate them. The ciphers are guaranteed to be allocated when the device is registered however, so we should be able to free it safely on unregister.

---

 net/d80211/ieee80211.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/d80211/ieee80211.c +1 -0
index 6e10db5..926d160 100644
@@ -4715,6 +4715,7 @@ void ieee80211_unregister_hw(struct ieee
 	skb_queue_purge(&local->skb_queue_unreliable);
 
 	ieee80211_dev_free_index(local);
+	ieee80211_wep_free(local);
 	ieee80211_led_exit(local);
 }
 EXPORT_SYMBOL(ieee80211_unregister_hw);

net/d80211/ieee80211.c void ieee80211_free_hw(struct ieee80211_ · line 4730

Quoted 7 lines
net/d80211/ieee80211.c +0 -1
@@ -4724,7 +4725,6 @@ void ieee80211_free_hw(struct ieee80211_
 	struct ieee80211_local *local = hw_to_local(hw);
 
 	ieee80211_if_free(local->mdev);
-	ieee80211_wep_free(local);
 	ieee80211_dev_free(local);
 }
 EXPORT_SYMBOL(ieee80211_free_hw);

OK. Your patch fixes the issue I've seen as well, and seems a bit cleaner.

Applied
#3 lore raw
In reply to Michael Wu
Quoted 6 lines · Michael Wu
Quoted 2 lines · Gertjan van Wingerde

The d80211 stack still tries to free the WEP crypto ciphers, even when allocating them previously has failed.

Actually, the code might not even have tried to allocate them. The ciphers are guaranteed to be allocated when the device is registered however, so we should be able to free it safely on unregister.

Applied to my tree, thanks for the patch.

Jiri

Signature · 2 lines
Jiri Benc
SUSE Labs