Commit cc0c53f
wifi: iwlwifi: mvm: Fix __counted_by usage in cfg80211_wowlan_nd_*
Both struct cfg80211_wowlan_nd_match and struct cfg80211_wowlan_nd_info
pre-allocate space for channels and matches, but then may end up using
fewer that the full allocation. Shrink the associated counter
(n_channels and n_matches) after counting the results. This avoids
compile-time (and run-time) warnings from __counted_by. (The counter
member needs to be updated _before_ accessing the array index.)
Seen with coming GCC 15:
drivers/net/wireless/intel/iwlwifi/mvm/d3.c: In function 'iwl_mvm_query_set_freqs':
drivers/net/wireless/intel/iwlwifi/mvm/d3.c:2877:66: warning: operation on 'match->n_channels' may be undefined [-Wsequence-point]
2877 | match->channels[match->n_channels++] =
| ~~~~~~~~~~~~~~~~~^~
drivers/net/wireless/intel/iwlwifi/mvm/d3.c:2885:66: warning: operation on 'match->n_channels' may be undefined [-Wsequence-point]
2885 | match->channels[match->n_channels++] =
| ~~~~~~~~~~~~~~~~~^~
drivers/net/wireless/intel/iwlwifi/mvm/d3.c: In function 'iwl_mvm_query_netdetect_reasons':
drivers/net/wireless/intel/iwlwifi/mvm/d3.c:2982:58: warning: operation on 'net_detect->n_matches' may be undefined [-Wsequence-point]
2982 | net_detect->matches[net_detect->n_matches++] = match;
| ~~~~~~~~~~~~~~~~~~~~~^~
Cc: stable@vger.kernel.org
Fixes: aa4ec06 ("wifi: cfg80211: use __counted_by where appropriate")
Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://patch.msgid.link/20240619211233.work.355-kees@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>1 parent b83accf commit cc0c53f
1 file changed
Lines changed: 11 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2954 | 2954 | | |
2955 | 2955 | | |
2956 | 2956 | | |
| 2957 | + | |
2957 | 2958 | | |
2958 | 2959 | | |
2959 | 2960 | | |
| |||
2962 | 2963 | | |
2963 | 2964 | | |
2964 | 2965 | | |
2965 | | - | |
| 2966 | + | |
2966 | 2967 | | |
2967 | 2968 | | |
2968 | 2969 | | |
2969 | 2970 | | |
2970 | 2971 | | |
2971 | 2972 | | |
2972 | 2973 | | |
2973 | | - | |
| 2974 | + | |
2974 | 2975 | | |
2975 | 2976 | | |
| 2977 | + | |
| 2978 | + | |
2976 | 2979 | | |
2977 | 2980 | | |
2978 | 2981 | | |
| |||
3053 | 3056 | | |
3054 | 3057 | | |
3055 | 3058 | | |
| 3059 | + | |
| 3060 | + | |
3056 | 3061 | | |
3057 | 3062 | | |
3058 | 3063 | | |
| |||
3066 | 3071 | | |
3067 | 3072 | | |
3068 | 3073 | | |
| 3074 | + | |
3069 | 3075 | | |
3070 | | - | |
| 3076 | + | |
3071 | 3077 | | |
3072 | 3078 | | |
3073 | 3079 | | |
| |||
3082 | 3088 | | |
3083 | 3089 | | |
3084 | 3090 | | |
| 3091 | + | |
| 3092 | + | |
3085 | 3093 | | |
3086 | 3094 | | |
3087 | 3095 | | |
| |||
0 commit comments