wifi: nl80211: Set num_sub_specs before looping through sub_specs
authorKees Cook <kees@kernel.org>
Mon, 21 Jul 2025 18:31:29 +0000 (11:31 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 22 Jul 2025 08:38:39 +0000 (10:38 +0200)
commit2ed9a9fc9976262109d04f1a3c75c46de8ce4f22
treeaea0d5b72ccbed8d40d8a64f9aa1a90c3ccdf6f1
parenta37192c432adaec9e8ef29e4ddb319ea2f443aa6
wifi: nl80211: Set num_sub_specs before looping through sub_specs

The processing of the struct cfg80211_sar_specs::sub_specs flexible
array requires its counter, num_sub_specs, to be assigned before the
loop in nl80211_set_sar_specs(). Leave the final assignment after the
loop in place in case fewer ended up in the array.

Fixes: aa4ec06c455d ("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/20250721183125.work.183-kees@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/nl80211.c