netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.4 01/29] wifi: rtw88: phy: fix warning of possible buffer overflow
@ 2022-10-09 22:22 Sasha Levin
  2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 02/29] wifi: brcmfmac: fix invalid address access when enabling SCAN log level Sasha Levin
                   ` (25 more replies)
  0 siblings, 26 replies; 28+ messages in thread
From: Sasha Levin @ 2022-10-09 22:22 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Zong-Zhe Yang, Ping-Ke Shih, Kalle Valo, Sasha Levin,
	tony0620emma, davem, edumazet, kuba, pabeni, linux-wireless,
	netdev

From: Zong-Zhe Yang <kevin_yang@realtek.com>

[ Upstream commit 86331c7e0cd819bf0c1d0dcf895e0c90b0aa9a6f ]

reported by smatch

phy.c:854 rtw_phy_linear_2_db() error: buffer overflow 'db_invert_table[i]'
8 <= 8 (assuming for loop doesn't break)

However, it seems to be a false alarm because we prevent it originally via
       if (linear >= db_invert_table[11][7])
               return 96; /* maximum 96 dB */

Still, we adjust the code to be more readable and avoid smatch warning.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220727065003.28340-5-pkshih@realtek.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/wireless/realtek/rtw88/phy.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/phy.c b/drivers/net/wireless/realtek/rtw88/phy.c
index 02da69e9dfe7..2227bbd14644 100644
--- a/drivers/net/wireless/realtek/rtw88/phy.c
+++ b/drivers/net/wireless/realtek/rtw88/phy.c
@@ -586,23 +586,18 @@ static u8 rtw_phy_linear_2_db(u64 linear)
 	u8 j;
 	u32 dB;
 
-	if (linear >= db_invert_table[11][7])
-		return 96; /* maximum 96 dB */
-
 	for (i = 0; i < 12; i++) {
-		if (i <= 2 && (linear << FRAC_BITS) <= db_invert_table[i][7])
-			break;
-		else if (i > 2 && linear <= db_invert_table[i][7])
-			break;
+		for (j = 0; j < 8; j++) {
+			if (i <= 2 && (linear << FRAC_BITS) <= db_invert_table[i][j])
+				goto cnt;
+			else if (i > 2 && linear <= db_invert_table[i][j])
+				goto cnt;
+		}
 	}
 
-	for (j = 0; j < 8; j++) {
-		if (i <= 2 && (linear << FRAC_BITS) <= db_invert_table[i][j])
-			break;
-		else if (i > 2 && linear <= db_invert_table[i][j])
-			break;
-	}
+	return 96; /* maximum 96 dB */
 
+cnt:
 	if (j == 0 && i == 0)
 		goto end;
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2022-10-10 13:33 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-09 22:22 [PATCH AUTOSEL 5.4 01/29] wifi: rtw88: phy: fix warning of possible buffer overflow Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 02/29] wifi: brcmfmac: fix invalid address access when enabling SCAN log level Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 04/29] openvswitch: Fix double reporting of drops in dropwatch Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 05/29] openvswitch: Fix overreporting " Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 06/29] tcp: annotate data-race around tcp_md5sig_pool_populated Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 07/29] wifi: ath9k: avoid uninit memory read in ath9k_htc_rx_msg() Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 08/29] xfrm: Update ipcomp_scratches with NULL when freed Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 09/29] net: xscale: Fix return type for implementation of ndo_start_xmit Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 10/29] net: lantiq_etop: " Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 11/29] net: ftmac100: fix endianness-related issues from 'sparse' Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 12/29] wifi: brcmfmac: fix use-after-free bug in brcmf_netdev_start_xmit() Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 13/29] Bluetooth: L2CAP: initialize delayed works at l2cap_chan_create() Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 14/29] net: davicom: Fix return type of dm9000_start_xmit Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 15/29] net: ethernet: ti: davinci_emac: Fix return type of emac_dev_xmit Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 16/29] net: korina: Fix return type of korina_send_packet Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 17/29] net/sched: taprio: taprio_dump and taprio_change are protected by rtnl_mutex Sasha Levin
2022-10-10 13:33   ` Vladimir Oltean
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 18/29] Bluetooth: hci_sysfs: Fix attempting to call device_add multiple times Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 19/29] wifi: ath10k: reset pointer after memory free to avoid potential use-after-free Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 20/29] can: bcm: check the result of can_send() in bcm_can_tx() Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 21/29] wifi: rt2x00: don't run Rt5592 IQ calibration on MT7620 Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 22/29] wifi: rt2x00: set correct TX_SW_CFG1 MAC register for MT7620 Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 23/29] wifi: rt2x00: set VGC gain for both chains of MT7620 Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 24/29] wifi: rt2x00: set SoC wmac clock register Sasha Levin
2022-10-09 22:23 ` [PATCH AUTOSEL 5.4 25/29] wifi: rt2x00: correctly set BBP register 86 for MT7620 Sasha Levin
2022-10-09 22:23 ` [PATCH AUTOSEL 5.4 26/29] net: If sock is dead don't access sock's sk_wq in sk_stream_wait_memory Sasha Levin
2022-10-09 22:23 ` [PATCH AUTOSEL 5.4 27/29] Bluetooth: L2CAP: Fix user-after-free Sasha Levin
2022-10-09 22:23 ` [PATCH AUTOSEL 5.4 29/29] r8152: Rate limit overflow messages Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).