cfg80211: constify wowlan/coalesce mask/pattern pointers
authorJohannes Berg <johannes.berg@intel.com>
Mon, 19 May 2014 15:59:50 +0000 (17:59 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 19 May 2014 16:06:50 +0000 (18:06 +0200)
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>
drivers/net/wireless/ti/wlcore/main.c
drivers/net/wireless/ti/wlcore/wlcore_i.h
include/net/cfg80211.h
net/wireless/nl80211.c

index 077eb5b9cd74c7a119c1e74ebbb109477a857ff3..02c91d6db753bdadaa9d5ed3953dff82a7a85065 100644 (file)
@@ -1416,7 +1416,7 @@ void wl1271_rx_filter_free(struct wl12xx_rx_filter *filter)
 
 int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter,
                                 u16 offset, u8 flags,
-                                u8 *pattern, u8 len)
+                                const u8 *pattern, u8 len)
 {
        struct wl12xx_rx_filter_field *field;
 
index 756e890bc5ee2be0a5f68ef3e37de397ccc8dd52..c2c34a84ff3d4bf7231f84933564b0e78dcc415b 100644 (file)
@@ -512,8 +512,8 @@ int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif);
 void wl12xx_queue_recovery_work(struct wl1271 *wl);
 size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen);
 int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter,
-                                       u16 offset, u8 flags,
-                                       u8 *pattern, u8 len);
+                                u16 offset, u8 flags,
+                                const u8 *pattern, u8 len);
 void wl1271_rx_filter_free(struct wl12xx_rx_filter *filter);
 struct wl12xx_rx_filter *wl1271_rx_filter_alloc(void);
 int wl1271_rx_filter_get_fields_size(struct wl12xx_rx_filter *filter);
index 3299d1b731ef7ddbc578831989ba9d0f02f67b3b..fe4fa287f7881c0a2beaef965bdf20be3d986988 100644 (file)
@@ -1827,7 +1827,7 @@ struct cfg80211_pmksa {
  * memory, free @mask only!
  */
 struct cfg80211_pkt_pattern {
-       u8 *mask, *pattern;
+       const u8 *mask, *pattern;
        int pattern_len;
        int pkt_offset;
 };
index ca19b1520389262729303a00b6dfd0cfa895ce15..49adf58646e6cc101e39212eb83a7e5de962326c 100644 (file)
@@ -8554,6 +8554,8 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
 
                nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
                                    rem) {
+                       u8 *mask_pat;
+
                        nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
                                  nla_len(pat), NULL);
                        err = -EINVAL;
@@ -8577,19 +8579,18 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
                                goto error;
                        new_triggers.patterns[i].pkt_offset = pkt_offset;
 
-                       new_triggers.patterns[i].mask =
-                               kmalloc(mask_len + pat_len, GFP_KERNEL);
-                       if (!new_triggers.patterns[i].mask) {
+                       mask_pat = kmalloc(mask_len + pat_len, GFP_KERNEL);
+                       if (!mask_pat) {
                                err = -ENOMEM;
                                goto error;
                        }
-                       new_triggers.patterns[i].pattern =
-                               new_triggers.patterns[i].mask + mask_len;
-                       memcpy(new_triggers.patterns[i].mask,
-                              nla_data(pat_tb[NL80211_PKTPAT_MASK]),
+                       new_triggers.patterns[i].mask = mask_pat;
+                       memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_MASK]),
                               mask_len);
+                       mask_pat += mask_len;
+                       new_triggers.patterns[i].pattern = mask_pat;
                        new_triggers.patterns[i].pattern_len = pat_len;
-                       memcpy(new_triggers.patterns[i].pattern,
+                       memcpy(mask_pat,
                               nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
                               pat_len);
                        i++;
@@ -8781,6 +8782,8 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
 
        nla_for_each_nested(pat, tb[NL80211_ATTR_COALESCE_RULE_PKT_PATTERN],
                            rem) {
+               u8 *mask_pat;
+
                nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
                          nla_len(pat), NULL);
                if (!pat_tb[NL80211_PKTPAT_MASK] ||
@@ -8802,17 +8805,19 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
                        return -EINVAL;
                new_rule->patterns[i].pkt_offset = pkt_offset;
 
-               new_rule->patterns[i].mask =
-                       kmalloc(mask_len + pat_len, GFP_KERNEL);
-               if (!new_rule->patterns[i].mask)
+               mask_pat = kmalloc(mask_len + pat_len, GFP_KERNEL);
+               if (!mask_pat)
                        return -ENOMEM;
-               new_rule->patterns[i].pattern =
-                       new_rule->patterns[i].mask + mask_len;
-               memcpy(new_rule->patterns[i].mask,
-                      nla_data(pat_tb[NL80211_PKTPAT_MASK]), mask_len);
+
+               new_rule->patterns[i].mask = mask_pat;
+               memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_MASK]),
+                      mask_len);
+
+               mask_pat += mask_len;
+               new_rule->patterns[i].pattern = mask_pat;
                new_rule->patterns[i].pattern_len = pat_len;
-               memcpy(new_rule->patterns[i].pattern,
-                      nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), pat_len);
+               memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
+                      pat_len);
                i++;
        }