Subject: [PATCH] d80211: don't symlink empty default keys

From: Jan Kiszka <[email-masked]>
Date: Tue, 09 Jan 2007 23:33:34 +0100

This gets rid of annoying

wlan0: cannot create symlink to default key

in my syslog with latest rt2x00. The patch takes care that in case of
(key/old_key == NULL && set_tx_key) the existing default key symlink is
removed correctly. Moreover, it tests for key!=NULL before trying to register
a new default link.

Signed-off-by: Jan Kiszka <[email-masked]>

---
 ieee80211/ieee80211_ioctl.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: rt2x00/ieee80211/ieee80211_ioctl.c
===================================================================
--- rt2x00.orig/ieee80211/ieee80211_ioctl.c
+++ rt2x00/ieee80211/ieee80211_ioctl.c
@@ -629,7 +629,7 @@ static int ieee80211_set_encryption(stru
 		}
 		kfree(keyconf);
 
-		if (key && sdata->default_key == key) {
+		if (set_tx_key || (key && sdata->default_key == key)) {
 			ieee80211_key_sysfs_remove_default(sdata);
 			sdata->default_key = NULL;
 		}
@@ -673,7 +673,7 @@ static int ieee80211_set_encryption(stru
 			}
 		}
 
-		if (old_key && sdata->default_key == old_key) {
+		if (set_tx_key || (old_key && sdata->default_key == old_key)) {
 			ieee80211_key_sysfs_remove_default(sdata);
 			sdata->default_key = NULL;
 		}
@@ -700,7 +700,7 @@ static int ieee80211_set_encryption(stru
 
 	if (set_tx_key || (!sta && !sdata->default_key && key)) {
 		sdata->default_key = key;
-		if (ieee80211_key_sysfs_add_default(sdata))
+		if (key && ieee80211_key_sysfs_add_default(sdata))
 			printk(KERN_WARNING "%s: cannot create symlink to "
 			       "default key\n", dev->name);
 		if (local->ops->set_key_idx &&