]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
wifi: mt76: add missing lock protection in mt76_sta_state for sta_event callback
authorZiyi Guo <n7l8m4@u.northwestern.edu>
Sat, 31 Jan 2026 03:52:10 +0000 (03:52 +0000)
committerFelix Fietkau <nbd@nbd.name>
Tue, 24 Mar 2026 15:49:30 +0000 (15:49 +0000)
commitf0168f2f9a1eca55d3ae09d8250b94e82b67cac3
treef657208ed0eaf7254d8ac642983a7ad9de688ed6
parent3dc0c40d7806c72cfe88cf4e1e2650c1673f9db4
wifi: mt76: add missing lock protection in mt76_sta_state for sta_event callback

mt76_sta_state() calls the sta_event callback without holding dev->mutex.
However, mt7915_mac_sta_event() (MT7915 implementation of this callback)
calls mt7915_mac_twt_teardown_flow() which has
lockdep_assert_held(&dev->mt76.mutex) indicating that callers must
hold this lock.

The locking pattern in mt76_sta_state() is inconsistent:
- mt76_sta_add() acquires dev->mutex before calling dev->drv->sta_add
- mt76_sta_remove() acquires dev->mutex before calling __mt76_sta_remove
- But sta_event callback is called without acquiring the lock

Add mutex_lock()/mutex_unlock() around the mt7915_mac_twt_teardown_flow
invocation to fix the missing lock protection and maintain consistency
with the existing locking pattern.

Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
Link: https://patch.msgid.link/20260131035210.2198259-1-n7l8m4@u.northwestern.edu
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7915/main.c