diff mbox series

[v1] net/mac80211/agg-tx: check the return value of rcu_dereference_protected_tid_tx()

Message ID 20220902075725.2214351-1-floridsleeves@gmail.com (mailing list archive)
State Rejected
Delegated to: Johannes Berg
Headers show
Series [v1] net/mac80211/agg-tx: check the return value of rcu_dereference_protected_tid_tx() | expand

Commit Message

Li Zhong Sept. 2, 2022, 7:57 a.m. UTC
From: lily <floridsleeves@gmail.com>

Check the return value of rcu_dereference_protected_tid_tx(), which
could be NULL and result in null pointer dereference if not checked.

Signed-off-by: Li Zhong <floridsleeves@gmail.com>
---
 net/mac80211/agg-tx.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Johannes Berg Sept. 2, 2022, 2:43 p.m. UTC | #1
On Fri, 2022-09-02 at 00:57 -0700, Li Zhong wrote:
> From: lily <floridsleeves@gmail.com>
> 
> Check the return value of rcu_dereference_protected_tid_tx(), which
> could be NULL and result in null pointer dereference if not checked.
> 

Except ... it can't happen?

johannes
diff mbox series

Patch

diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
index 07c892aa8c73..ce5f4a39bce2 100644
--- a/net/mac80211/agg-tx.c
+++ b/net/mac80211/agg-tx.c
@@ -503,6 +503,8 @@  void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid)
 	int ret;
 
 	tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
+	if (!tid_tx)
+		return;
 
 	/*
 	 * Start queuing up packets for this aggregation session.
@@ -742,6 +744,8 @@  static void ieee80211_agg_tx_operational(struct ieee80211_local *local,
 	lockdep_assert_held(&sta->ampdu_mlme.mtx);
 
 	tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
+	if (!tid_tx)
+		return;
 	params.buf_size = tid_tx->buf_size;
 	params.amsdu = tid_tx->amsdu;