Patch "wifi: mt76: fix coverity overrun-call in mt76_get_txpower()" has been added to the 6.0-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    wifi: mt76: fix coverity overrun-call in mt76_get_txpower()

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     wifi-mt76-fix-coverity-overrun-call-in-mt76_get_txpo.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit a60848adf00a684d1fcabea0d8a4b1263a615b5f
Author: Deren Wu <deren.wu@xxxxxxxxxxxx>
Date:   Sun Nov 27 10:35:37 2022 +0800

    wifi: mt76: fix coverity overrun-call in mt76_get_txpower()
    
    [ Upstream commit 03dd0d49de7db680a856fa566963bb8421f46368 ]
    
    Make sure the nss is valid for nss_delta array. Return zero
    if the index is invalid.
    
    Coverity message:
    Event overrun-call: Overrunning callee's array of size 4 by passing
    argument "n_chains" (which evaluates to 15) in call to
    "mt76_tx_power_nss_delta".
    int delta = mt76_tx_power_nss_delta(n_chains);
    
    Fixes: 07cda406308b ("mt76: fix rounding issues on converting per-chain and combined txpower")
    Signed-off-by: Deren Wu <deren.wu@xxxxxxxxxxxx>
    Signed-off-by: Felix Fietkau <nbd@xxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 4da77d47b0a6..1f8da524a305 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -1101,8 +1101,9 @@ static inline bool mt76_is_skb_pktid(u8 pktid)
 static inline u8 mt76_tx_power_nss_delta(u8 nss)
 {
 	static const u8 nss_delta[4] = { 0, 6, 9, 12 };
+	u8 idx = nss - 1;
 
-	return nss_delta[nss - 1];
+	return (idx < ARRAY_SIZE(nss_delta)) ? nss_delta[idx] : 0;
 }
 
 static inline bool mt76_testmode_enabled(struct mt76_phy *phy)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux