All of lore.kernel.org
 help / color / mirror / Atom feed
From: gregory.greenman@intel.com
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org,
	Benjamin Berg <benjamin.berg@intel.com>,
	Gregory Greenman <gregory.greenman@intel.com>
Subject: [PATCH 06/15] wifi: mac80211: add more warnings about inserting sta info
Date: Sun, 27 Aug 2023 14:05:23 +0300	[thread overview]
Message-ID: <20230827135854.eeb43b3cc9e3.I5fd8236f70e64bf6268f33c883f7a878d963b83e@changeid> (raw)
In-Reply-To: <20230827110532.348304-1-gregory.greenman@intel.com>

From: Benjamin Berg <benjamin.berg@intel.com>

The sta info needs to be inserted before its links may be modified.
Add a few warnings to prevent accidental usage of these functions.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
---
 net/mac80211/sta_info.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 7751f8ba960e..86f8bb878dbd 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -2874,6 +2874,8 @@ int ieee80211_sta_allocate_link(struct sta_info *sta, unsigned int link_id)
 
 	lockdep_assert_held(&sdata->local->sta_mtx);
 
+	WARN_ON(!test_sta_flag(sta, WLAN_STA_INSERTED));
+
 	/* must represent an MLD from the start */
 	if (WARN_ON(!sta->sta.valid_links))
 		return -EINVAL;
@@ -2903,6 +2905,8 @@ void ieee80211_sta_free_link(struct sta_info *sta, unsigned int link_id)
 {
 	lockdep_assert_held(&sta->sdata->local->sta_mtx);
 
+	WARN_ON(!test_sta_flag(sta, WLAN_STA_INSERTED));
+
 	sta_remove_link(sta, link_id, false);
 }
 
@@ -2930,7 +2934,7 @@ int ieee80211_sta_activate_link(struct sta_info *sta, unsigned int link_id)
 
 	sta->sta.valid_links = new_links;
 
-	if (!test_sta_flag(sta, WLAN_STA_INSERTED))
+	if (WARN_ON(!test_sta_flag(sta, WLAN_STA_INSERTED)))
 		goto hash;
 
 	ieee80211_recalc_min_chandef(sdata, link_id);
@@ -2963,7 +2967,7 @@ void ieee80211_sta_remove_link(struct sta_info *sta, unsigned int link_id)
 
 	sta->sta.valid_links &= ~BIT(link_id);
 
-	if (test_sta_flag(sta, WLAN_STA_INSERTED))
+	if (!WARN_ON(!test_sta_flag(sta, WLAN_STA_INSERTED)))
 		drv_change_sta_links(sdata->local, sdata, &sta->sta,
 				     old_links, sta->sta.valid_links);
 
-- 
2.38.1


  parent reply	other threads:[~2023-08-27 11:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-27 11:05 [PATCH 00/15] cfg80211/mac80211 patches from our internal tree 2023-08-27 gregory.greenman
2023-08-27 11:05 ` [PATCH 01/15] wifi: mac80211: add support for mld in ieee80211_chswitch_done gregory.greenman
2023-08-27 16:43   ` Jeff Johnson
2023-08-27 16:50     ` Grumbach, Emmanuel
2023-08-27 11:05 ` [PATCH 02/15] wifi: cfg80211: fix off-by-one in element defrag gregory.greenman
2023-08-27 11:05 ` [PATCH 03/15] wifi: cfg80211: add first kunit tests, for " gregory.greenman
2023-08-27 11:05 ` [PATCH 04/15] wifi: mac80211: add an element parsing unit test gregory.greenman
2023-09-04 15:23   ` Kalle Valo
2023-08-27 11:05 ` [PATCH 05/15] wifi: cfg80211: add ieee80211_fragment_element to public API gregory.greenman
2023-08-27 11:05 ` gregory.greenman [this message]
2023-08-27 11:05 ` [PATCH 07/15] wifi: mac80211: remove unnecessary struct forward declaration gregory.greenman
2023-08-27 11:05 ` [PATCH 08/15] wifi: mac80211: fix various kernel-doc issues gregory.greenman
2023-08-27 11:05 ` [PATCH 09/15] wifi: cfg80211: reg: " gregory.greenman
2023-08-27 11:05 ` [PATCH 10/15] wifi: mac80211_hwsim: clean up kernel-doc gregory.greenman
2023-08-27 11:05 ` [PATCH 11/15] wifi: mac80211: fix # of MSDU in A-MSDU calculation gregory.greenman
2023-08-27 11:05 ` [PATCH 12/15] wifi: mac80211: Print local link address during authentication gregory.greenman
2023-08-28 10:37   ` Wen Gong
2023-08-27 11:05 ` [PATCH 13/15] wifi: mac80211: take MBSSID/EHT data also from probe resp gregory.greenman
2023-08-27 11:05 ` [PATCH 14/15] wifi: mac80211: Do not force off-channel for management Tx with MLO gregory.greenman
2023-08-27 11:05 ` [PATCH 15/15] wifi: mac80211: fix channel switch link data gregory.greenman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230827135854.eeb43b3cc9e3.I5fd8236f70e64bf6268f33c883f7a878d963b83e@changeid \
    --to=gregory.greenman@intel.com \
    --cc=benjamin.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.