Skip to content

Commit

Permalink
wifi: mac80211: pass 'sta' to ieee80211_rx_data_set_sta()
Browse files Browse the repository at this point in the history
[ Upstream commit 0d846bd ]

There's at least one case in ieee80211_rx_for_interface()
where we might pass &((struct sta_info *)NULL)->sta to it
only to then do container_of(), and then checking the
result for NULL, but checking the result of container_of()
for NULL looks really odd.

Fix this by just passing the struct sta_info * instead.

Fixes: e66b792 ("wifi: mac80211: fix initialization of rx->link and rx->link_sta")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
jmberg-intel authored and gregkh committed Mar 10, 2023
1 parent ec2c00f commit 8c46157
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions net/mac80211/rx.c
Expand Up @@ -4094,13 +4094,8 @@ static bool ieee80211_rx_data_set_link(struct ieee80211_rx_data *rx,
}

static bool ieee80211_rx_data_set_sta(struct ieee80211_rx_data *rx,
struct ieee80211_sta *pubsta,
int link_id)
struct sta_info *sta, int link_id)
{
struct sta_info *sta;

sta = container_of(pubsta, struct sta_info, sta);

rx->link_id = link_id;
rx->sta = sta;

Expand Down Expand Up @@ -4138,7 +4133,7 @@ void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid)
if (sta->sta.valid_links)
link_id = ffs(sta->sta.valid_links) - 1;

if (!ieee80211_rx_data_set_sta(&rx, &sta->sta, link_id))
if (!ieee80211_rx_data_set_sta(&rx, sta, link_id))
return;

tid_agg_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]);
Expand Down Expand Up @@ -4184,7 +4179,7 @@ void ieee80211_mark_rx_ba_filtered_frames(struct ieee80211_sta *pubsta, u8 tid,

sta = container_of(pubsta, struct sta_info, sta);

if (!ieee80211_rx_data_set_sta(&rx, pubsta, -1))
if (!ieee80211_rx_data_set_sta(&rx, sta, -1))
return;

rcu_read_lock();
Expand Down Expand Up @@ -4892,6 +4887,7 @@ static void __ieee80211_rx_handle_8023(struct ieee80211_hw *hw,
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
struct ieee80211_fast_rx *fast_rx;
struct ieee80211_rx_data rx;
struct sta_info *sta;
int link_id = -1;

memset(&rx, 0, sizeof(rx));
Expand Down Expand Up @@ -4919,7 +4915,8 @@ static void __ieee80211_rx_handle_8023(struct ieee80211_hw *hw,
* link_id is used only for stats purpose and updating the stats on
* the deflink is fine?
*/
if (!ieee80211_rx_data_set_sta(&rx, pubsta, link_id))
sta = container_of(pubsta, struct sta_info, sta);
if (!ieee80211_rx_data_set_sta(&rx, sta, link_id))
goto drop;

fast_rx = rcu_dereference(rx.sta->fast_rx);
Expand Down Expand Up @@ -4959,7 +4956,7 @@ static bool ieee80211_rx_for_interface(struct ieee80211_rx_data *rx,
link_id = status->link_id;
}

if (!ieee80211_rx_data_set_sta(rx, &sta->sta, link_id))
if (!ieee80211_rx_data_set_sta(rx, sta, link_id))
return false;

return ieee80211_prepare_and_rx_handle(rx, skb, consume);
Expand Down Expand Up @@ -5026,7 +5023,8 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
link_id = status->link_id;

if (pubsta) {
if (!ieee80211_rx_data_set_sta(&rx, pubsta, link_id))
sta = container_of(pubsta, struct sta_info, sta);
if (!ieee80211_rx_data_set_sta(&rx, sta, link_id))
goto out;

/*
Expand Down Expand Up @@ -5063,8 +5061,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
}

rx.sdata = prev_sta->sdata;
if (!ieee80211_rx_data_set_sta(&rx, &prev_sta->sta,
link_id))
if (!ieee80211_rx_data_set_sta(&rx, prev_sta, link_id))
goto out;

if (!status->link_valid && prev_sta->sta.mlo)
Expand All @@ -5077,8 +5074,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,

if (prev_sta) {
rx.sdata = prev_sta->sdata;
if (!ieee80211_rx_data_set_sta(&rx, &prev_sta->sta,
link_id))
if (!ieee80211_rx_data_set_sta(&rx, prev_sta, link_id))
goto out;

if (!status->link_valid && prev_sta->sta.mlo)
Expand Down

0 comments on commit 8c46157

Please sign in to comment.