mt76: mt7663s: fix a possible ple quota underflow
authorLorenzo Bianconi <lorenzo@kernel.org>
Mon, 5 Oct 2020 15:22:23 +0000 (17:22 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Dec 2020 10:53:35 +0000 (11:53 +0100)
[ Upstream commit 1c79a190e94325e01811f653f770a34e816fdd8f ]

Properly account current consumed ple quota in mt7663s_tx_pick_quota
routine and avoid possible underflow.

Fixes: 6ef2d665f64d ("mt76: mt7663s: split mt7663s_tx_update_sched in mt7663s_tx_{pick,update}_quota")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c

index 2486cda..69e38f4 100644 (file)
@@ -150,7 +150,7 @@ static int mt7663s_tx_pick_quota(struct mt76_sdio *sdio, enum mt76_txq_id qid,
                        return -EBUSY;
        } else {
                if (sdio->sched.pse_data_quota < *pse_size + pse_sz ||
-                   sdio->sched.ple_data_quota < *ple_size)
+                   sdio->sched.ple_data_quota < *ple_size + 1)
                        return -EBUSY;
 
                *ple_size = *ple_size + 1;