wifi: mac80211: mlme: fix non-inheritence element
There were two bugs when creating the non-inheritence
element:
1) 'at_extension' needs to be declared outside the loop,
otherwise the value resets every iteration and we
can never really switch properly
2) 'added' never got set to true, so we always cut off
the extension element again at the end of the function
This shows another issue that we might add a list but no
extension list, but we need to make the extension list a
zero-length one in that case.
Fix all these issues. While at it, add a comment explaining
the trim.
Fixes: 81151ce462
("wifi: mac80211: support MLO authentication/association with one link")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230604120651.3addaa5c4782.If3a78f9305997ad7ef4ba7ffc17a8234c956f613@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
727073ca5e
commit
68c228557d
|
@ -1217,6 +1217,7 @@ static void ieee80211_add_non_inheritance_elem(struct sk_buff *skb,
|
||||||
const u16 *inner)
|
const u16 *inner)
|
||||||
{
|
{
|
||||||
unsigned int skb_len = skb->len;
|
unsigned int skb_len = skb->len;
|
||||||
|
bool at_extension = false;
|
||||||
bool added = false;
|
bool added = false;
|
||||||
int i, j;
|
int i, j;
|
||||||
u8 *len, *list_len = NULL;
|
u8 *len, *list_len = NULL;
|
||||||
|
@ -1228,7 +1229,6 @@ static void ieee80211_add_non_inheritance_elem(struct sk_buff *skb,
|
||||||
for (i = 0; i < PRESENT_ELEMS_MAX && outer[i]; i++) {
|
for (i = 0; i < PRESENT_ELEMS_MAX && outer[i]; i++) {
|
||||||
u16 elem = outer[i];
|
u16 elem = outer[i];
|
||||||
bool have_inner = false;
|
bool have_inner = false;
|
||||||
bool at_extension = false;
|
|
||||||
|
|
||||||
/* should at least be sorted in the sense of normal -> ext */
|
/* should at least be sorted in the sense of normal -> ext */
|
||||||
WARN_ON(at_extension && elem < PRESENT_ELEM_EXT_OFFS);
|
WARN_ON(at_extension && elem < PRESENT_ELEM_EXT_OFFS);
|
||||||
|
@ -1257,8 +1257,14 @@ static void ieee80211_add_non_inheritance_elem(struct sk_buff *skb,
|
||||||
}
|
}
|
||||||
*list_len += 1;
|
*list_len += 1;
|
||||||
skb_put_u8(skb, (u8)elem);
|
skb_put_u8(skb, (u8)elem);
|
||||||
|
added = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if we added a list but no extension list, make a zero-len one */
|
||||||
|
if (added && (!at_extension || !list_len))
|
||||||
|
skb_put_u8(skb, 0);
|
||||||
|
|
||||||
|
/* if nothing added remove extension element completely */
|
||||||
if (!added)
|
if (!added)
|
||||||
skb_trim(skb, skb_len);
|
skb_trim(skb, skb_len);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue