mt76_cancel_remain_on_channel() reads mvif->roc_phy and phy->roc_vif without dev->mutex, while mt76_roc_complete() clears both under the mutex before it reports the expiry. A cancel during a completion thus returns before the expiry reaches mac80211, and the late expiry ends the next request. ieee80211_cancel_roc() relies on the opposite: Note that this assumes that by the time the driver returns from drv_cancel_remain_on_channel, it has completed all the processing of related notifications. Look up the request of the interface under dev->mutex, so that a completion in progress has reported the expiry before the cancel returns. Fixes: a8f424c1287c ("wifi: mt76: add multi-radio remain_on_channel functions") Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/channel.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/channel.c b/drivers/net/wireless/mediatek/mt76/channel.c index df655cc56349..9638f65a679e 100644 --- a/drivers/net/wireless/mediatek/mt76/channel.c +++ b/drivers/net/wireless/mediatek/mt76/channel.c @@ -507,14 +507,16 @@ EXPORT_SYMBOL_GPL(mt76_remain_on_channel); int mt76_cancel_remain_on_channel(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct mt76_vif_link *mlink = (struct mt76_vif_link *)vif->drv_priv; - struct mt76_vif_data *mvif = mlink->mvif; - struct mt76_phy *phy = mvif->roc_phy; + struct mt76_phy *phy = hw->priv; + struct mt76_dev *dev = phy->dev; - if (!phy || phy->roc_vif != vif) - return 0; + /* a completion holds the mutex until it reported the expiry */ + mutex_lock(&dev->mutex); + phy = mt76_vif_roc_phy(dev, vif); + mutex_unlock(&dev->mutex); - mt76_abort_roc(phy); + if (phy) + mt76_abort_roc(phy); return 0; } -- 2.47.3