Commit 2bd7e35d authored by Johannes Berg's avatar Johannes Berg

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: default avatarJohannes Berg <johannes.berg@intel.com>
parent 878d9ec7
...@@ -5230,21 +5230,18 @@ static int nl80211_testmode_dump(struct sk_buff *skb, ...@@ -5230,21 +5230,18 @@ static int nl80211_testmode_dump(struct sk_buff *skb,
nl80211_policy); nl80211_policy);
if (err) if (err)
return 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), mutex_lock(&cfg80211_mutex);
nl80211_fam.attrbuf, rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk),
&rdev, &netdev); nl80211_fam.attrbuf);
if (err) if (IS_ERR(rdev)) {
return err; mutex_unlock(&cfg80211_mutex);
dev_put(netdev); return PTR_ERR(rdev);
phy_idx = rdev->wiphy_idx;
cfg80211_unlock_rdev(rdev);
} }
phy_idx = rdev->wiphy_idx;
rdev = NULL;
mutex_unlock(&cfg80211_mutex);
if (nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA]) if (nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA])
cb->args[1] = cb->args[1] =
(long)nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA]; (long)nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA];
......
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