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>
This commit is contained in:
parent
c1e5f4714d
commit
922bd80fc3
@ -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,
|
int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter,
|
||||||
u16 offset, u8 flags,
|
u16 offset, u8 flags,
|
||||||
u8 *pattern, u8 len)
|
const u8 *pattern, u8 len)
|
||||||
{
|
{
|
||||||
struct wl12xx_rx_filter_field *field;
|
struct wl12xx_rx_filter_field *field;
|
||||||
|
|
||||||
|
@ -512,8 +512,8 @@ int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif);
|
|||||||
void wl12xx_queue_recovery_work(struct wl1271 *wl);
|
void wl12xx_queue_recovery_work(struct wl1271 *wl);
|
||||||
size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen);
|
size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen);
|
||||||
int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter,
|
int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter,
|
||||||
u16 offset, u8 flags,
|
u16 offset, u8 flags,
|
||||||
u8 *pattern, u8 len);
|
const u8 *pattern, u8 len);
|
||||||
void wl1271_rx_filter_free(struct wl12xx_rx_filter *filter);
|
void wl1271_rx_filter_free(struct wl12xx_rx_filter *filter);
|
||||||
struct wl12xx_rx_filter *wl1271_rx_filter_alloc(void);
|
struct wl12xx_rx_filter *wl1271_rx_filter_alloc(void);
|
||||||
int wl1271_rx_filter_get_fields_size(struct wl12xx_rx_filter *filter);
|
int wl1271_rx_filter_get_fields_size(struct wl12xx_rx_filter *filter);
|
||||||
|
@ -1827,7 +1827,7 @@ struct cfg80211_pmksa {
|
|||||||
* memory, free @mask only!
|
* memory, free @mask only!
|
||||||
*/
|
*/
|
||||||
struct cfg80211_pkt_pattern {
|
struct cfg80211_pkt_pattern {
|
||||||
u8 *mask, *pattern;
|
const u8 *mask, *pattern;
|
||||||
int pattern_len;
|
int pattern_len;
|
||||||
int pkt_offset;
|
int pkt_offset;
|
||||||
};
|
};
|
||||||
|
@ -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],
|
nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
|
||||||
rem) {
|
rem) {
|
||||||
|
u8 *mask_pat;
|
||||||
|
|
||||||
nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
|
nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
|
||||||
nla_len(pat), NULL);
|
nla_len(pat), NULL);
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
@ -8577,19 +8579,18 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
|
|||||||
goto error;
|
goto error;
|
||||||
new_triggers.patterns[i].pkt_offset = pkt_offset;
|
new_triggers.patterns[i].pkt_offset = pkt_offset;
|
||||||
|
|
||||||
new_triggers.patterns[i].mask =
|
mask_pat = kmalloc(mask_len + pat_len, GFP_KERNEL);
|
||||||
kmalloc(mask_len + pat_len, GFP_KERNEL);
|
if (!mask_pat) {
|
||||||
if (!new_triggers.patterns[i].mask) {
|
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
new_triggers.patterns[i].pattern =
|
new_triggers.patterns[i].mask = mask_pat;
|
||||||
new_triggers.patterns[i].mask + mask_len;
|
memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_MASK]),
|
||||||
memcpy(new_triggers.patterns[i].mask,
|
|
||||||
nla_data(pat_tb[NL80211_PKTPAT_MASK]),
|
|
||||||
mask_len);
|
mask_len);
|
||||||
|
mask_pat += mask_len;
|
||||||
|
new_triggers.patterns[i].pattern = mask_pat;
|
||||||
new_triggers.patterns[i].pattern_len = pat_len;
|
new_triggers.patterns[i].pattern_len = pat_len;
|
||||||
memcpy(new_triggers.patterns[i].pattern,
|
memcpy(mask_pat,
|
||||||
nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
|
nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
|
||||||
pat_len);
|
pat_len);
|
||||||
i++;
|
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],
|
nla_for_each_nested(pat, tb[NL80211_ATTR_COALESCE_RULE_PKT_PATTERN],
|
||||||
rem) {
|
rem) {
|
||||||
|
u8 *mask_pat;
|
||||||
|
|
||||||
nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
|
nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
|
||||||
nla_len(pat), NULL);
|
nla_len(pat), NULL);
|
||||||
if (!pat_tb[NL80211_PKTPAT_MASK] ||
|
if (!pat_tb[NL80211_PKTPAT_MASK] ||
|
||||||
@ -8802,17 +8805,19 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
new_rule->patterns[i].pkt_offset = pkt_offset;
|
new_rule->patterns[i].pkt_offset = pkt_offset;
|
||||||
|
|
||||||
new_rule->patterns[i].mask =
|
mask_pat = kmalloc(mask_len + pat_len, GFP_KERNEL);
|
||||||
kmalloc(mask_len + pat_len, GFP_KERNEL);
|
if (!mask_pat)
|
||||||
if (!new_rule->patterns[i].mask)
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
new_rule->patterns[i].pattern =
|
|
||||||
new_rule->patterns[i].mask + mask_len;
|
new_rule->patterns[i].mask = mask_pat;
|
||||||
memcpy(new_rule->patterns[i].mask,
|
memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_MASK]),
|
||||||
nla_data(pat_tb[NL80211_PKTPAT_MASK]), mask_len);
|
mask_len);
|
||||||
|
|
||||||
|
mask_pat += mask_len;
|
||||||
|
new_rule->patterns[i].pattern = mask_pat;
|
||||||
new_rule->patterns[i].pattern_len = pat_len;
|
new_rule->patterns[i].pattern_len = pat_len;
|
||||||
memcpy(new_rule->patterns[i].pattern,
|
memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
|
||||||
nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), pat_len);
|
pat_len);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user