Commit 35a8efe1 authored by Jouni Malinen's avatar Jouni Malinen Committed by John W. Linville

nl80211: Check that netif_runnin is true in cfg80211 code

We do not want to require all the drivers using cfg80211 to need to do
this or to be prepared to handle these commands when the interface is
down.
Signed-off-by: default avatarJouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 255e737e
...@@ -728,10 +728,6 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, ...@@ -728,10 +728,6 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
int err; int err;
int layer2_update; int layer2_update;
/* Prevent a race with changing the rate control algorithm */
if (!netif_running(dev))
return -ENETDOWN;
if (params->vlan) { if (params->vlan) {
sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
...@@ -860,9 +856,6 @@ static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, ...@@ -860,9 +856,6 @@ static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
struct sta_info *sta; struct sta_info *sta;
int err; int err;
if (!netif_running(dev))
return -ENETDOWN;
sdata = IEEE80211_DEV_TO_SUB_IF(dev); sdata = IEEE80211_DEV_TO_SUB_IF(dev);
if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT) if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
...@@ -913,9 +906,6 @@ static int ieee80211_change_mpath(struct wiphy *wiphy, ...@@ -913,9 +906,6 @@ static int ieee80211_change_mpath(struct wiphy *wiphy,
struct mesh_path *mpath; struct mesh_path *mpath;
struct sta_info *sta; struct sta_info *sta;
if (!netif_running(dev))
return -ENETDOWN;
sdata = IEEE80211_DEV_TO_SUB_IF(dev); sdata = IEEE80211_DEV_TO_SUB_IF(dev);
if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT) if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
...@@ -1202,9 +1192,6 @@ static int ieee80211_scan(struct wiphy *wiphy, ...@@ -1202,9 +1192,6 @@ static int ieee80211_scan(struct wiphy *wiphy,
{ {
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
if (!netif_running(dev))
return -ENETDOWN;
sdata = IEEE80211_DEV_TO_SUB_IF(dev); sdata = IEEE80211_DEV_TO_SUB_IF(dev);
if (sdata->vif.type != NL80211_IFTYPE_STATION && if (sdata->vif.type != NL80211_IFTYPE_STATION &&
...@@ -1220,9 +1207,6 @@ static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev, ...@@ -1220,9 +1207,6 @@ static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
{ {
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
if (!netif_running(dev))
return -ENETDOWN;
sdata = IEEE80211_DEV_TO_SUB_IF(dev); sdata = IEEE80211_DEV_TO_SUB_IF(dev);
if (sdata->vif.type != NL80211_IFTYPE_STATION) if (sdata->vif.type != NL80211_IFTYPE_STATION)
...@@ -1282,9 +1266,6 @@ static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, ...@@ -1282,9 +1266,6 @@ static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
int ret; int ret;
if (!netif_running(dev))
return -ENETDOWN;
sdata = IEEE80211_DEV_TO_SUB_IF(dev); sdata = IEEE80211_DEV_TO_SUB_IF(dev);
if (sdata->vif.type != NL80211_IFTYPE_STATION) if (sdata->vif.type != NL80211_IFTYPE_STATION)
...@@ -1323,9 +1304,6 @@ static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev, ...@@ -1323,9 +1304,6 @@ static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
{ {
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
if (!netif_running(dev))
return -ENETDOWN;
sdata = IEEE80211_DEV_TO_SUB_IF(dev); sdata = IEEE80211_DEV_TO_SUB_IF(dev);
if (sdata->vif.type != NL80211_IFTYPE_STATION) if (sdata->vif.type != NL80211_IFTYPE_STATION)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -1339,9 +1317,6 @@ static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, ...@@ -1339,9 +1317,6 @@ static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
{ {
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
if (!netif_running(dev))
return -ENETDOWN;
sdata = IEEE80211_DEV_TO_SUB_IF(dev); sdata = IEEE80211_DEV_TO_SUB_IF(dev);
if (sdata->vif.type != NL80211_IFTYPE_STATION) if (sdata->vif.type != NL80211_IFTYPE_STATION)
......
...@@ -1556,6 +1556,11 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) ...@@ -1556,6 +1556,11 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
goto out; goto out;
} }
if (!netif_running(dev)) {
err = -ENETDOWN;
goto out;
}
err = drv->ops->add_station(&drv->wiphy, dev, mac_addr, &params); err = drv->ops->add_station(&drv->wiphy, dev, mac_addr, &params);
out: out:
...@@ -1808,6 +1813,11 @@ static int nl80211_set_mpath(struct sk_buff *skb, struct genl_info *info) ...@@ -1808,6 +1813,11 @@ static int nl80211_set_mpath(struct sk_buff *skb, struct genl_info *info)
goto out; goto out;
} }
if (!netif_running(dev)) {
err = -ENETDOWN;
goto out;
}
err = drv->ops->change_mpath(&drv->wiphy, dev, dst, next_hop); err = drv->ops->change_mpath(&drv->wiphy, dev, dst, next_hop);
out: out:
...@@ -1846,6 +1856,11 @@ static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info) ...@@ -1846,6 +1856,11 @@ static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info)
goto out; goto out;
} }
if (!netif_running(dev)) {
err = -ENETDOWN;
goto out;
}
err = drv->ops->add_mpath(&drv->wiphy, dev, dst, next_hop); err = drv->ops->add_mpath(&drv->wiphy, dev, dst, next_hop);
out: out:
...@@ -2380,6 +2395,11 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) ...@@ -2380,6 +2395,11 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
goto out; goto out;
} }
if (!netif_running(dev)) {
err = -ENETDOWN;
goto out;
}
if (drv->scan_req) { if (drv->scan_req) {
err = -EBUSY; err = -EBUSY;
goto out; goto out;
...@@ -2641,6 +2661,11 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) ...@@ -2641,6 +2661,11 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
goto out; goto out;
} }
if (!netif_running(dev)) {
err = -ENETDOWN;
goto out;
}
if (!info->attrs[NL80211_ATTR_MAC]) { if (!info->attrs[NL80211_ATTR_MAC]) {
err = -EINVAL; err = -EINVAL;
goto out; goto out;
...@@ -2709,6 +2734,11 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) ...@@ -2709,6 +2734,11 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
goto out; goto out;
} }
if (!netif_running(dev)) {
err = -ENETDOWN;
goto out;
}
if (!info->attrs[NL80211_ATTR_MAC] || if (!info->attrs[NL80211_ATTR_MAC] ||
!info->attrs[NL80211_ATTR_SSID]) { !info->attrs[NL80211_ATTR_SSID]) {
err = -EINVAL; err = -EINVAL;
...@@ -2767,6 +2797,11 @@ static int nl80211_deauthenticate(struct sk_buff *skb, struct genl_info *info) ...@@ -2767,6 +2797,11 @@ static int nl80211_deauthenticate(struct sk_buff *skb, struct genl_info *info)
goto out; goto out;
} }
if (!netif_running(dev)) {
err = -ENETDOWN;
goto out;
}
if (!info->attrs[NL80211_ATTR_MAC]) { if (!info->attrs[NL80211_ATTR_MAC]) {
err = -EINVAL; err = -EINVAL;
goto out; goto out;
...@@ -2821,6 +2856,11 @@ static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info) ...@@ -2821,6 +2856,11 @@ static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info)
goto out; goto out;
} }
if (!netif_running(dev)) {
err = -ENETDOWN;
goto out;
}
if (!info->attrs[NL80211_ATTR_MAC]) { if (!info->attrs[NL80211_ATTR_MAC]) {
err = -EINVAL; err = -EINVAL;
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment