Skip to content

Commit

Permalink
cfg80211: avoid setting default_key if add_key fails
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Zhu Yi authored and John W. Linville committed Jul 24, 2009
1 parent 971ad01 commit 1e05666
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions net/wireless/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 1e05666

Please sign in to comment.