diff mbox series

cfg80211: hold bss_lock while updating nontrans_list

Message ID 1649868067-23974-1-git-send-email-quic_ramess@quicinc.com
State New
Headers show
Series cfg80211: hold bss_lock while updating nontrans_list | expand

Commit Message

Rameshkumar Sundaram April 13, 2022, 4:41 p.m. UTC
Synchronize additions to nontrans_list of transmitting BSS with
bss_lock to avoid races. Also when cfg80211_add_nontrans_list() fails
__cfg80211_unlink_bss() needs bss_lock to be held (has lockdep assert
on bss_lock). So protect the whole block with bss_lock to avoid
races and warnings. Found during code review.

Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning")
Signed-off-by: Rameshkumar Sundaram <quic_ramess@quicinc.com>
---
 net/wireless/scan.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index b888522..286cfe3 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -2011,11 +2011,13 @@  cfg80211_inform_single_bss_data(struct wiphy *wiphy,
 		/* this is a nontransmitting bss, we need to add it to
 		 * transmitting bss' list if it is not there
 		 */
+		spin_lock_bh(&rdev->bss_lock);
 		if (cfg80211_add_nontrans_list(non_tx_data->tx_bss,
 					       &res->pub)) {
 			if (__cfg80211_unlink_bss(rdev, res))
 				rdev->bss_generation++;
 		}
+		spin_unlock_bh(&rdev->bss_lock);
 	}
 
 	trace_cfg80211_return_bss(&res->pub);