diff options
Diffstat (limited to 'net/wireless/nl80211.c')
-rw-r--r-- | net/wireless/nl80211.c | 76 |
1 files changed, 33 insertions, 43 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 17bcad69428d..4dc139cdba5c 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -152,6 +152,26 @@ nl80211_key_policy[NL80211_KEY_MAX + 1] __read_mostly = { | |||
152 | [NL80211_KEY_DEFAULT_MGMT] = { .type = NLA_FLAG }, | 152 | [NL80211_KEY_DEFAULT_MGMT] = { .type = NLA_FLAG }, |
153 | }; | 153 | }; |
154 | 154 | ||
155 | /* ifidx get helper */ | ||
156 | static int nl80211_get_ifidx(struct netlink_callback *cb) | ||
157 | { | ||
158 | int res; | ||
159 | |||
160 | res = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize, | ||
161 | nl80211_fam.attrbuf, nl80211_fam.maxattr, | ||
162 | nl80211_policy); | ||
163 | if (res) | ||
164 | return res; | ||
165 | |||
166 | if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]) | ||
167 | return -EINVAL; | ||
168 | |||
169 | res = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]); | ||
170 | if (!res) | ||
171 | return -EINVAL; | ||
172 | return res; | ||
173 | } | ||
174 | |||
155 | /* IE validation */ | 175 | /* IE validation */ |
156 | static bool is_valid_ie_attr(const struct nlattr *attr) | 176 | static bool is_valid_ie_attr(const struct nlattr *attr) |
157 | { | 177 | { |
@@ -1693,20 +1713,10 @@ static int nl80211_dump_station(struct sk_buff *skb, | |||
1693 | int sta_idx = cb->args[1]; | 1713 | int sta_idx = cb->args[1]; |
1694 | int err; | 1714 | int err; |
1695 | 1715 | ||
1696 | if (!ifidx) { | 1716 | if (!ifidx) |
1697 | err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize, | 1717 | ifidx = nl80211_get_ifidx(cb); |
1698 | nl80211_fam.attrbuf, nl80211_fam.maxattr, | 1718 | if (ifidx < 0) |
1699 | nl80211_policy); | 1719 | return ifidx; |
1700 | if (err) | ||
1701 | return err; | ||
1702 | |||
1703 | if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]) | ||
1704 | return -EINVAL; | ||
1705 | |||
1706 | ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]); | ||
1707 | if (!ifidx) | ||
1708 | return -EINVAL; | ||
1709 | } | ||
1710 | 1720 | ||
1711 | rtnl_lock(); | 1721 | rtnl_lock(); |
1712 | 1722 | ||
@@ -2156,20 +2166,10 @@ static int nl80211_dump_mpath(struct sk_buff *skb, | |||
2156 | int path_idx = cb->args[1]; | 2166 | int path_idx = cb->args[1]; |
2157 | int err; | 2167 | int err; |
2158 | 2168 | ||
2159 | if (!ifidx) { | 2169 | if (!ifidx) |
2160 | err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize, | 2170 | ifidx = nl80211_get_ifidx(cb); |
2161 | nl80211_fam.attrbuf, nl80211_fam.maxattr, | 2171 | if (ifidx < 0) |
2162 | nl80211_policy); | 2172 | return ifidx; |
2163 | if (err) | ||
2164 | return err; | ||
2165 | |||
2166 | if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]) | ||
2167 | return -EINVAL; | ||
2168 | |||
2169 | ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]); | ||
2170 | if (!ifidx) | ||
2171 | return -EINVAL; | ||
2172 | } | ||
2173 | 2173 | ||
2174 | rtnl_lock(); | 2174 | rtnl_lock(); |
2175 | 2175 | ||
@@ -3198,21 +3198,11 @@ static int nl80211_dump_scan(struct sk_buff *skb, | |||
3198 | int start = cb->args[1], idx = 0; | 3198 | int start = cb->args[1], idx = 0; |
3199 | int err; | 3199 | int err; |
3200 | 3200 | ||
3201 | if (!ifidx) { | 3201 | if (!ifidx) |
3202 | err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize, | 3202 | ifidx = nl80211_get_ifidx(cb); |
3203 | nl80211_fam.attrbuf, nl80211_fam.maxattr, | 3203 | if (ifidx < 0) |
3204 | nl80211_policy); | 3204 | return ifidx; |
3205 | if (err) | 3205 | cb->args[0] = ifidx; |
3206 | return err; | ||
3207 | |||
3208 | if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]) | ||
3209 | return -EINVAL; | ||
3210 | |||
3211 | ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]); | ||
3212 | if (!ifidx) | ||
3213 | return -EINVAL; | ||
3214 | cb->args[0] = ifidx; | ||
3215 | } | ||
3216 | 3206 | ||
3217 | dev = dev_get_by_index(sock_net(skb->sk), ifidx); | 3207 | dev = dev_get_by_index(sock_net(skb->sk), ifidx); |
3218 | if (!dev) | 3208 | if (!dev) |