diff mbox series

wifi: brcmsmac: add gain range check to wlc_phy_iqcal_gainparams_nphy()

Message ID 20241210070441.836362-1-dmantipov@yandex.ru (mailing list archive)
State Accepted
Commit 3f4a0948c3524ae50f166dbc6572a3296b014e62
Delegated to: Kalle Valo
Headers show
Series wifi: brcmsmac: add gain range check to wlc_phy_iqcal_gainparams_nphy() | expand

Commit Message

Dmitry Antipov Dec. 10, 2024, 7:04 a.m. UTC
In 'wlc_phy_iqcal_gainparams_nphy()', add gain range check to WARN()
instead of possible out-of-bounds 'tbl_iqcal_gainparams_nphy' access.
Compile tested only.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Arend van Spriel Dec. 13, 2024, 12:30 p.m. UTC | #1
On December 10, 2024 8:04:45 AM Dmitry Antipov <dmantipov@yandex.ru> wrote:

> In 'wlc_phy_iqcal_gainparams_nphy()', add gain range check to WARN()
> instead of possible out-of-bounds 'tbl_iqcal_gainparams_nphy' access.
> Compile tested only.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.

Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
> drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c | 3 +++
> 1 file changed, 3 insertions(+)
Kalle Valo Dec. 13, 2024, 12:55 p.m. UTC | #2
Dmitry Antipov <dmantipov@yandex.ru> wrote:

> In 'wlc_phy_iqcal_gainparams_nphy()', add gain range check to WARN()
> instead of possible out-of-bounds 'tbl_iqcal_gainparams_nphy' access.
> Compile tested only.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>

Patch applied to wireless-next.git, thanks.

3f4a0948c352 wifi: brcmsmac: add gain range check to wlc_phy_iqcal_gainparams_nphy()
diff mbox series

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
index d69879e1bd87..d362c4337616 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
@@ -23423,6 +23423,9 @@  wlc_phy_iqcal_gainparams_nphy(struct brcms_phy *pi, u16 core_no,
 				break;
 		}
 
+		if (WARN_ON(k == NPHY_IQCAL_NUMGAINS))
+			return;
+
 		params->txgm = tbl_iqcal_gainparams_nphy[band_idx][k][1];
 		params->pga = tbl_iqcal_gainparams_nphy[band_idx][k][2];
 		params->pad = tbl_iqcal_gainparams_nphy[band_idx][k][3];