From: Hong Liu <hong.liu@xxxxxxxxx> Signed-off-by: Hong Liu <hong.liu@xxxxxxxxx> Signed-off-by: Jiri Benc <jbenc@xxxxxxx> --- net/mac80211/ieee80211_ioctl.c | 22 ++++++++++------------ 1 files changed, 10 insertions(+), 12 deletions(-) 1485998df4d688be3e0907423a774dadbf90a631 diff --git a/net/mac80211/ieee80211_ioctl.c b/net/mac80211/ieee80211_ioctl.c index 21a17eb..b28e794 100644 --- a/net/mac80211/ieee80211_ioctl.c +++ b/net/mac80211/ieee80211_ioctl.c @@ -2924,19 +2924,17 @@ static int ieee80211_ioctl_siwencode(str sdata = IEEE80211_DEV_TO_SUB_IF(dev); idx = erq->flags & IW_ENCODE_INDEX; - if (idx < 1 || idx > 4) { - idx = -1; - if (!sdata->default_key) - idx = 0; - else for (i = 0; i < NUM_DEFAULT_KEYS; i++) { - if (sdata->default_key == sdata->keys[i]) { - idx = i; - break; + if (idx == 0) { + if (sdata->default_key) + for (i = 0; i < NUM_DEFAULT_KEYS; i++) { + if (sdata->default_key == sdata->keys[i]) { + idx = i; + break; + } } - } - if (idx < 0) - return -EINVAL; - } else + } else if (idx < 1 || idx > 4) + return -EINVAL; + else idx--; if (erq->flags & IW_ENCODE_DISABLED) -- 1.3.0 - To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html