wifi: mac80211: Write cnt before copying in ieee80211_copy_rnr_beacon()
authorKees Cook <kees@kernel.org>
Mon, 21 Jul 2025 18:25:22 +0000 (11:25 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 22 Jul 2025 08:38:21 +0000 (10:38 +0200)
commita37192c432adaec9e8ef29e4ddb319ea2f443aa6
tree3cc1ab0285aed91149107cde01606fcafdeea2a7
parentee0e5ce2790c5be14ea3d422cac323e059a43792
wifi: mac80211: Write cnt before copying in ieee80211_copy_rnr_beacon()

While I caught the need for setting cnt early in nl80211_parse_rnr_elems()
in the original annotation of struct cfg80211_rnr_elems with __counted_by,
I missed a similar pattern in ieee80211_copy_rnr_beacon(). Fix this by
moving the cnt assignment to before the loop.

Fixes: 7b6d7087031b ("wifi: cfg80211: Annotate struct cfg80211_rnr_elems with __counted_by")
Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://patch.msgid.link/20250721182521.work.540-kees@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/cfg.c