public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wifi: mac80211: tx: Add __must_hold() annotation
@ 2024-01-13  1:11 Brent Pappas
  2024-01-13  6:32 ` Kalle Valo
  2024-01-13 17:27 ` [PATCH v2] " Brent Pappas
  0 siblings, 2 replies; 6+ messages in thread
From: Brent Pappas @ 2024-01-13  1:11 UTC (permalink / raw)
  To: Johannes Berg, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: Brent Pappas, linux-wireless, netdev, linux-kernel

Annotates ieee80211_set_beacon_cntdwn() with a __must_hold() annotation to
make it clear that ieee80211_set_beacon_cntdwn() is only intended to be
called when the caller has a lock on the argument "link."

Signed-off-by: Brent Pappas <bpappas@pappasbrent.com>
---

Currently, ieee80211_set_beacon_cntdwn() calls rcu_dereference(), but
without calling rcu_read_lock() beforehand and rcu_read_unlock()
afterward.  At first I thought this was a bug, since (if I understand the
RCU API correctly) rcu_dereference() should only be called in RCU
read-side critical sections. However, upon closer inspection of the code,
I realized that ieee80211_set_beacon_cntdwn() is only ever called inside
critical sections. Therefore it seems appropriate to me to annotate
ieee80211_set_beacon_cntdwn() with a __must_hold() annotation to make this
apparent precondition explicit.

This is my first time submitting an RCU-related patch so please tell me if
I am misunderstanding the RCU API.

 net/mac80211/tx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 314998fdb1a5..7245f2e641ba 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -10,6 +10,7 @@
  * Transmit and frame generation functions.
  */
 
+#include "linux/compiler_types.h"
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/skbuff.h>
@@ -4974,6 +4975,7 @@ static int ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata,
 static void ieee80211_set_beacon_cntdwn(struct ieee80211_sub_if_data *sdata,
 					struct beacon_data *beacon,
 					struct ieee80211_link_data *link)
+	__must_hold(link)
 {
 	u8 *beacon_data, count, max_count = 1;
 	struct probe_resp *resp;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-01-17 23:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-13  1:11 [PATCH] wifi: mac80211: tx: Add __must_hold() annotation Brent Pappas
2024-01-13  6:32 ` Kalle Valo
2024-01-15 13:13   ` Johannes Berg
2024-01-17 20:00     ` Brent Pappas
2024-01-17 23:07       ` Johannes Berg
2024-01-13 17:27 ` [PATCH v2] " Brent Pappas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox