Skip to content

Commit 496db69

Browse files
learjet5jmberg-intel
authored andcommitted
wifi: mac80211: init cnt before accessing elem in ieee80211_copy_mbssid_beacon
With the new __counted_by annocation in cfg80211_mbssid_elems, the "cnt" struct member must be set before accessing the "elem" array. Failing to do so will trigger a runtime warning when enabling CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE. Fixes: c14679d ("wifi: cfg80211: Annotate struct cfg80211_mbssid_elems with __counted_by") Signed-off-by: Haoyu Li <lihaoyu499@gmail.com> Link: https://patch.msgid.link/20241123172500.311853-1-lihaoyu499@gmail.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 49dba1d commit 496db69

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/mac80211/cfg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,13 +1088,13 @@ ieee80211_copy_mbssid_beacon(u8 *pos, struct cfg80211_mbssid_elems *dst,
10881088
{
10891089
int i, offset = 0;
10901090

1091+
dst->cnt = src->cnt;
10911092
for (i = 0; i < src->cnt; i++) {
10921093
memcpy(pos + offset, src->elem[i].data, src->elem[i].len);
10931094
dst->elem[i].len = src->elem[i].len;
10941095
dst->elem[i].data = pos + offset;
10951096
offset += dst->elem[i].len;
10961097
}
1097-
dst->cnt = src->cnt;
10981098

10991099
return offset;
11001100
}

0 commit comments

Comments
 (0)