cfg80211: avoid setting default_key if add_key fails
authorZhu Yi <yi.zhu@intel.com>
Mon, 20 Jul 2009 08:12:57 +0000 (16:12 +0800)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 24 Jul 2009 19:05:29 +0000 (15:05 -0400)
In cfg80211_upload_connect_keys(), we call add_key, set_default_key
and set_default_mgmt_key (if applicable) one by one. If one of these
operations fails, we should stop calling the following functions.
Because if the key is not added successfully, we should not set it as
default key anyway.

Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/wireless/util.c

index 4bab380a12040bfc4acf28a8db79723902aa91b2..ba387d85dcfde3c63b277fbf6181e0a1e8bb5141 100644 (file)
@@ -546,13 +546,17 @@ void cfg80211_upload_connect_keys(struct wireless_dev *wdev)
                if (!wdev->connect_keys->params[i].cipher)
                        continue;
                if (rdev->ops->add_key(wdev->wiphy, dev, i, NULL,
-                                       &wdev->connect_keys->params[i]))
+                                       &wdev->connect_keys->params[i])) {
                        printk(KERN_ERR "%s: failed to set key %d\n",
                                dev->name, i);
+                       continue;
+               }
                if (wdev->connect_keys->def == i)
-                       if (rdev->ops->set_default_key(wdev->wiphy, dev, i))
+                       if (rdev->ops->set_default_key(wdev->wiphy, dev, i)) {
                                printk(KERN_ERR "%s: failed to set defkey %d\n",
                                        dev->name, i);
+                               continue;
+                       }
                if (wdev->connect_keys->defmgmt == i)
                        if (rdev->ops->set_default_mgmt_key(wdev->wiphy, dev, i))
                                printk(KERN_ERR "%s: failed to set mgtdef %d\n",