From 5fe319a0550ecfeb621377c7a7af75510559d340 Mon Sep 17 00:00:00 2001 From: Deren Wu Date: Sun, 15 Jan 2023 12:44:57 +0800 Subject: [PATCH] wifi: mt76: add memory barrier to SDIO queue kick Ensure the entry has been fully updated before SDIO bus worker access it. This patch would fix potential memory risk in both mt7663s and mt7921s. Fixes: 764dee47e2c1 ("mt76: sdio: move common code in mt76_sdio module") Signed-off-by: Deren Wu Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Felix Fietkau --- sdio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sdio.c b/sdio.c index 228bc7d4..41972311 100644 --- a/sdio.c +++ b/sdio.c @@ -562,6 +562,10 @@ mt76s_tx_queue_skb_raw(struct mt76_dev *dev, struct mt76_queue *q, q->entry[q->head].buf_sz = len; q->entry[q->head].skb = skb; + + /* ensure the entry fully updated before bus access */ + smp_wmb(); + q->head = (q->head + 1) % q->ndesc; q->queued++;