Search Linux Wireless

[PATCH-v2] nl80211: Fix bug in match set count calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Match set count is calculated in nl80211_start_sched_scan() by counting
each attr available in NL80211_ATTR_SCHED_SCAN_MATCH. Some cases, RSSI
threshold limit NL80211_SCHED_SCAN_MATCH_ATTR_RSSI attr also can come
from user space along with NL80211_SCHED_SCAN_MATCH_ATTR_SSID attr.
In such cases, exiting code counts NL80211_SCHED_SCAN_MATCH_ATTR_RSSI
attr also as one of SSID and leads extra memory allocation for match set
array (request->match_sets).

Counting only NL80211_SCHED_SCAN_MATCH_ATTR_RSSI attr will help nl80211 to
allocate exact memory needed for match set array and also driver can know
the exact valid SSID available in match set array.

Signed-off-by: Raja Mani <rmani@xxxxxxxxxxxxxxxx>
---

V2 changes:
* Changed commit text and patch title as per johannas comments.

 net/wireless/nl80211.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index d0afd82..2d3a86f 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5504,11 +5504,17 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
 	if (n_ssids > wiphy->max_sched_scan_ssids)
 		return -EINVAL;
 
-	if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH])
+	if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH]) {
 		nla_for_each_nested(attr,
 				    info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH],
-				    tmp)
-			n_match_sets++;
+				    tmp) {
+			nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
+				  nla_data(attr), nla_len(attr),
+				  nl80211_match_policy);
+			if (tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID])
+				n_match_sets++;
+		}
+	}
 
 	if (n_match_sets > wiphy->max_match_sets)
 		return -EINVAL;
-- 
1.7.10.4

--
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




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux