Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+26 -21
+1 -1
drivers/net/wireless/ti/wlcore/main.c
··· 1416 1416 1417 1417 int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter, 1418 1418 u16 offset, u8 flags, 1419 - u8 *pattern, u8 len) 1419 + const u8 *pattern, u8 len) 1420 1420 { 1421 1421 struct wl12xx_rx_filter_field *field; 1422 1422
+2 -2
drivers/net/wireless/ti/wlcore/wlcore_i.h
··· 512 512 void wl12xx_queue_recovery_work(struct wl1271 *wl); 513 513 size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen); 514 514 int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter, 515 - u16 offset, u8 flags, 516 - u8 *pattern, u8 len); 515 + u16 offset, u8 flags, 516 + const u8 *pattern, u8 len); 517 517 void wl1271_rx_filter_free(struct wl12xx_rx_filter *filter); 518 518 struct wl12xx_rx_filter *wl1271_rx_filter_alloc(void); 519 519 int wl1271_rx_filter_get_fields_size(struct wl12xx_rx_filter *filter);
+1 -1
include/net/cfg80211.h
··· 1827 1827 * memory, free @mask only! 1828 1828 */ 1829 1829 struct cfg80211_pkt_pattern { 1830 - u8 *mask, *pattern; 1830 + const u8 *mask, *pattern; 1831 1831 int pattern_len; 1832 1832 int pkt_offset; 1833 1833 };
+22 -17
net/wireless/nl80211.c
··· 8554 8554 8555 8555 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN], 8556 8556 rem) { 8557 + u8 *mask_pat; 8558 + 8557 8559 nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), 8558 8560 nla_len(pat), NULL); 8559 8561 err = -EINVAL; ··· 8579 8577 goto error; 8580 8578 new_triggers.patterns[i].pkt_offset = pkt_offset; 8581 8579 8582 - new_triggers.patterns[i].mask = 8583 - kmalloc(mask_len + pat_len, GFP_KERNEL); 8584 - if (!new_triggers.patterns[i].mask) { 8580 + mask_pat = kmalloc(mask_len + pat_len, GFP_KERNEL); 8581 + if (!mask_pat) { 8585 8582 err = -ENOMEM; 8586 8583 goto error; 8587 8584 } 8588 - new_triggers.patterns[i].pattern = 8589 - new_triggers.patterns[i].mask + mask_len; 8590 - memcpy(new_triggers.patterns[i].mask, 8591 - nla_data(pat_tb[NL80211_PKTPAT_MASK]), 8585 + new_triggers.patterns[i].mask = mask_pat; 8586 + memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_MASK]), 8592 8587 mask_len); 8588 + mask_pat += mask_len; 8589 + new_triggers.patterns[i].pattern = mask_pat; 8593 8590 new_triggers.patterns[i].pattern_len = pat_len; 8594 - memcpy(new_triggers.patterns[i].pattern, 8591 + memcpy(mask_pat, 8595 8592 nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), 8596 8593 pat_len); 8597 8594 i++; ··· 8782 8781 8783 8782 nla_for_each_nested(pat, tb[NL80211_ATTR_COALESCE_RULE_PKT_PATTERN], 8784 8783 rem) { 8784 + u8 *mask_pat; 8785 + 8785 8786 nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), 8786 8787 nla_len(pat), NULL); 8787 8788 if (!pat_tb[NL80211_PKTPAT_MASK] || ··· 8805 8802 return -EINVAL; 8806 8803 new_rule->patterns[i].pkt_offset = pkt_offset; 8807 8804 8808 - new_rule->patterns[i].mask = 8809 - kmalloc(mask_len + pat_len, GFP_KERNEL); 8810 - if (!new_rule->patterns[i].mask) 8805 + mask_pat = kmalloc(mask_len + pat_len, GFP_KERNEL); 8806 + if (!mask_pat) 8811 8807 return -ENOMEM; 8812 - new_rule->patterns[i].pattern = 8813 - new_rule->patterns[i].mask + mask_len; 8814 - memcpy(new_rule->patterns[i].mask, 8815 - nla_data(pat_tb[NL80211_PKTPAT_MASK]), mask_len); 8808 + 8809 + new_rule->patterns[i].mask = mask_pat; 8810 + memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_MASK]), 8811 + mask_len); 8812 + 8813 + mask_pat += mask_len; 8814 + new_rule->patterns[i].pattern = mask_pat; 8816 8815 new_rule->patterns[i].pattern_len = pat_len; 8817 - memcpy(new_rule->patterns[i].pattern, 8818 - nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), pat_len); 8816 + memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), 8817 + pat_len); 8819 8818 i++; 8820 8819 } 8821 8820