aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2014-05-19 11:59:50 -0400
committerJohannes Berg <johannes.berg@intel.com>2014-05-19 12:06:50 -0400
commit922bd80fc33b5b90eb34b1485ebcf3c7b2e61618 (patch)
tree7f03c80775ba39c43d34f8038583db768b311029 /net/wireless
parentc1e5f4714d591cc0a5e986613fdefa61abe98ac2 (diff)
cfg80211: constify wowlan/coalesce mask/pattern pointers
This requires changing the nl80211 parsing code a bit to use intermediate pointers for the allocation, but clarifies the API towards the drivers. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/nl80211.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index ca19b1520389..49adf58646e6 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -8554,6 +8554,8 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
8554 8554
8555 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN], 8555 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
8556 rem) { 8556 rem) {
8557 u8 *mask_pat;
8558
8557 nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), 8559 nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
8558 nla_len(pat), NULL); 8560 nla_len(pat), NULL);
8559 err = -EINVAL; 8561 err = -EINVAL;
@@ -8577,19 +8579,18 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
8577 goto error; 8579 goto error;
8578 new_triggers.patterns[i].pkt_offset = pkt_offset; 8580 new_triggers.patterns[i].pkt_offset = pkt_offset;
8579 8581
8580 new_triggers.patterns[i].mask = 8582 mask_pat = kmalloc(mask_len + pat_len, GFP_KERNEL);
8581 kmalloc(mask_len + pat_len, GFP_KERNEL); 8583 if (!mask_pat) {
8582 if (!new_triggers.patterns[i].mask) {
8583 err = -ENOMEM; 8584 err = -ENOMEM;
8584 goto error; 8585 goto error;
8585 } 8586 }
8586 new_triggers.patterns[i].pattern = 8587 new_triggers.patterns[i].mask = mask_pat;
8587 new_triggers.patterns[i].mask + mask_len; 8588 memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_MASK]),
8588 memcpy(new_triggers.patterns[i].mask,
8589 nla_data(pat_tb[NL80211_PKTPAT_MASK]),
8590 mask_len); 8589 mask_len);
8590 mask_pat += mask_len;
8591 new_triggers.patterns[i].pattern = mask_pat;
8591 new_triggers.patterns[i].pattern_len = pat_len; 8592 new_triggers.patterns[i].pattern_len = pat_len;
8592 memcpy(new_triggers.patterns[i].pattern, 8593 memcpy(mask_pat,
8593 nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), 8594 nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
8594 pat_len); 8595 pat_len);
8595 i++; 8596 i++;
@@ -8781,6 +8782,8 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
8781 8782
8782 nla_for_each_nested(pat, tb[NL80211_ATTR_COALESCE_RULE_PKT_PATTERN], 8783 nla_for_each_nested(pat, tb[NL80211_ATTR_COALESCE_RULE_PKT_PATTERN],
8783 rem) { 8784 rem) {
8785 u8 *mask_pat;
8786
8784 nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), 8787 nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
8785 nla_len(pat), NULL); 8788 nla_len(pat), NULL);
8786 if (!pat_tb[NL80211_PKTPAT_MASK] || 8789 if (!pat_tb[NL80211_PKTPAT_MASK] ||
@@ -8802,17 +8805,19 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
8802 return -EINVAL; 8805 return -EINVAL;
8803 new_rule->patterns[i].pkt_offset = pkt_offset; 8806 new_rule->patterns[i].pkt_offset = pkt_offset;
8804 8807
8805 new_rule->patterns[i].mask = 8808 mask_pat = kmalloc(mask_len + pat_len, GFP_KERNEL);
8806 kmalloc(mask_len + pat_len, GFP_KERNEL); 8809 if (!mask_pat)
8807 if (!new_rule->patterns[i].mask)
8808 return -ENOMEM; 8810 return -ENOMEM;
8809 new_rule->patterns[i].pattern = 8811
8810 new_rule->patterns[i].mask + mask_len; 8812 new_rule->patterns[i].mask = mask_pat;
8811 memcpy(new_rule->patterns[i].mask, 8813 memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_MASK]),
8812 nla_data(pat_tb[NL80211_PKTPAT_MASK]), mask_len); 8814 mask_len);
8815
8816 mask_pat += mask_len;
8817 new_rule->patterns[i].pattern = mask_pat;
8813 new_rule->patterns[i].pattern_len = pat_len; 8818 new_rule->patterns[i].pattern_len = pat_len;
8814 memcpy(new_rule->patterns[i].pattern, 8819 memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
8815 nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), pat_len); 8820 pat_len);
8816 i++; 8821 i++;
8817 } 8822 }
8818 8823