summaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-06-15 14:23:16 +0200
committerJohannes Berg <johannes.berg@intel.com>2012-06-20 10:57:03 +0200
commit2bd7e35da011f51d4fdb3b71f888c3a50194bfcd (patch)
tree5c21d882b27059aef8db432bb92c83c02c23113e /net/wireless
parent878d9ec7367816dc336b0c24e6256596559692b7 (diff)
downloadlinux-2bd7e35da011f51d4fdb3b71f888c3a50194bfcd.tar.gz
linux-2bd7e35da011f51d4fdb3b71f888c3a50194bfcd.tar.bz2
linux-2bd7e35da011f51d4fdb3b71f888c3a50194bfcd.zip
nl80211: use __cfg80211_rdev_from_attrs for testmode
To fix the testmode cross-namespace access problem, use __cfg80211_rdev_from_attrs() to get the device instead of open-coding similar functionality. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/nl80211.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 7e94d4d960bf..06623d064606 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5230,21 +5230,18 @@ static int nl80211_testmode_dump(struct sk_buff *skb,
nl80211_policy);
if (err)
return err;
- if (nl80211_fam.attrbuf[NL80211_ATTR_WIPHY]) {
- phy_idx = nla_get_u32(
- nl80211_fam.attrbuf[NL80211_ATTR_WIPHY]);
- } else {
- struct net_device *netdev;
- err = get_rdev_dev_by_ifindex(sock_net(skb->sk),
- nl80211_fam.attrbuf,
- &rdev, &netdev);
- if (err)
- return err;
- dev_put(netdev);
- phy_idx = rdev->wiphy_idx;
- cfg80211_unlock_rdev(rdev);
+ mutex_lock(&cfg80211_mutex);
+ rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk),
+ nl80211_fam.attrbuf);
+ if (IS_ERR(rdev)) {
+ mutex_unlock(&cfg80211_mutex);
+ return PTR_ERR(rdev);
}
+ phy_idx = rdev->wiphy_idx;
+ rdev = NULL;
+ mutex_unlock(&cfg80211_mutex);
+
if (nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA])
cb->args[1] =
(long)nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA];