netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] d80211: Only free WEP crypto ciphers when they have been allocated correctly.
@ 2007-01-06 17:00 Gertjan van Wingerde
  2007-01-06 17:29 ` Michael Wu
  0 siblings, 1 reply; 4+ messages in thread
From: Gertjan van Wingerde @ 2007-01-06 17:00 UTC (permalink / raw)
  To: Jiri Benc, netdev

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.

Signed-off-by: Gertjan van Wingerde <gwingerde@kpnplanet.nl>

---
diff --git a/net/d80211/wep.c b/net/d80211/wep.c
index dee8eae..5abcda6 100644
--- a/net/d80211/wep.c
+++ b/net/d80211/wep.c
@@ -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)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] d80211: Only free WEP crypto ciphers when they have been allocated correctly.
  2007-01-06 17:00 [PATCH] d80211: Only free WEP crypto ciphers when they have been allocated correctly Gertjan van Wingerde
@ 2007-01-06 17:29 ` Michael Wu
  2007-01-06 18:14   ` Gertjan van Wingerde
  2007-01-10 20:14   ` Jiri Benc
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Wu @ 2007-01-06 17:29 UTC (permalink / raw)
  To: Gertjan van Wingerde; +Cc: Jiri Benc, netdev

[-- Attachment #1: Type: text/plain, Size: 1203 bytes --]

On Saturday 06 January 2007 12:00, Gertjan van Wingerde wrote:
> 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.

Signed-off-by: Michael Wu <flamingice@sourmilk.net>
---

 net/d80211/ieee80211.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/d80211/ieee80211.c b/net/d80211/ieee80211.c
index 6e10db5..926d160 100644
--- a/net/d80211/ieee80211.c
+++ b/net/d80211/ieee80211.c
@@ -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);


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] d80211: Only free WEP crypto ciphers when they have been allocated correctly.
  2007-01-06 17:29 ` Michael Wu
@ 2007-01-06 18:14   ` Gertjan van Wingerde
  2007-01-10 20:14   ` Jiri Benc
  1 sibling, 0 replies; 4+ messages in thread
From: Gertjan van Wingerde @ 2007-01-06 18:14 UTC (permalink / raw)
  To: Michael Wu, Jiri Benc, netdev

Michael Wu wrote:
> On Saturday 06 January 2007 12:00, Gertjan van Wingerde wrote:
>   
>> 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.
>
> Signed-off-by: Michael Wu <flamingice@sourmilk.net>
> ---
>
>  net/d80211/ieee80211.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/net/d80211/ieee80211.c b/net/d80211/ieee80211.c
> index 6e10db5..926d160 100644
> --- a/net/d80211/ieee80211.c
> +++ b/net/d80211/ieee80211.c
> @@ -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);
OK. Your patch fixes the issue I've seen as well, and seems a bit cleaner.

Acked-by: Gertjan van Wingerde <gwingerde@kpnplanet.nl>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] d80211: Only free WEP crypto ciphers when they have been allocated correctly.
  2007-01-06 17:29 ` Michael Wu
  2007-01-06 18:14   ` Gertjan van Wingerde
@ 2007-01-10 20:14   ` Jiri Benc
  1 sibling, 0 replies; 4+ messages in thread
From: Jiri Benc @ 2007-01-10 20:14 UTC (permalink / raw)
  To: Michael Wu; +Cc: Gertjan van Wingerde, netdev

On Sat, 6 Jan 2007 12:29:11 -0500, Michael Wu wrote:
> On Saturday 06 January 2007 12:00, Gertjan van Wingerde wrote:
> > 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

-- 
Jiri Benc
SUSE Labs

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-01-10 20:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-06 17:00 [PATCH] d80211: Only free WEP crypto ciphers when they have been allocated correctly Gertjan van Wingerde
2007-01-06 17:29 ` Michael Wu
2007-01-06 18:14   ` Gertjan van Wingerde
2007-01-10 20:14   ` Jiri Benc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).