Skip to content

Commit bf88b7c

Browse files
keesgregkh
authored andcommitted
wifi: mac80211: Write cnt before copying in ieee80211_copy_rnr_beacon()
[ Upstream commit a37192c ] 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: 7b6d708 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 50e98be commit bf88b7c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

net/mac80211/cfg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,13 +1099,13 @@ ieee80211_copy_rnr_beacon(u8 *pos, struct cfg80211_rnr_elems *dst,
10991099
{
11001100
int i, offset = 0;
11011101

1102+
dst->cnt = src->cnt;
11021103
for (i = 0; i < src->cnt; i++) {
11031104
memcpy(pos + offset, src->elem[i].data, src->elem[i].len);
11041105
dst->elem[i].len = src->elem[i].len;
11051106
dst->elem[i].data = pos + offset;
11061107
offset += dst->elem[i].len;
11071108
}
1108-
dst->cnt = src->cnt;
11091109

11101110
return offset;
11111111
}

0 commit comments

Comments
 (0)