linux-next/drivers/net/wireless
Kees Cook cc0c53f4fa 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: aa4ec06c45 ("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>
2024-12-18 18:34:57 +01:00
..
admtek wifi: mac80211: inform the low level if drv_stop() is a suspend 2024-06-26 10:25:46 +02:00
ath wireless-next patches for v6.13 2024-11-13 18:35:19 -08:00
atmel wifi: mac80211: inform the low level if drv_stop() is a suspend 2024-06-26 10:25:46 +02:00
broadcom module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
intel wifi: iwlwifi: mvm: Fix __counted_by usage in cfg80211_wowlan_nd_* 2024-12-18 18:34:57 +01:00
intersil wifi: p54: Use IRQF_NO_AUTOEN flag in request_irq() 2024-09-18 16:54:30 +03:00
marvell Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-10-31 18:10:07 -07:00
mediatek wireless-next patches for v6.13 2024-11-13 18:35:19 -08:00
microchip Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-10-31 18:10:07 -07:00
purelifi move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
quantenna wifi: cfg80211: disallow SMPS in AP mode 2024-10-23 16:43:03 +02:00
ralink Networking changes for 6.13. 2024-11-21 08:28:08 -08:00
realtek wireless-next patches for v6.13 2024-11-13 18:35:19 -08:00
rsi wifi: rsi: Remove an unused field in struct rsi_debugfs 2024-09-09 15:30:49 +03:00
silabs wifi: wfx: Fix error handling in wfx_core_init() 2024-10-31 16:18:42 +02:00
st wifi: cw1200: Fix potential NULL dereference 2024-10-31 16:20:02 +02:00
ti wifi: Switch back to struct platform_driver::remove() 2024-11-11 14:10:45 +02:00
virtual Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-10-31 18:10:07 -07:00
zydas move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
Kconfig wifi: remove orphaned rndis_wlan driver 2023-10-30 19:30:33 +02:00
Makefile wifi: remove orphaned rndis_wlan driver 2023-10-30 19:30:33 +02:00