linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] brcm80211: fix wrap around in conversion from constant to s16
@ 2018-06-17 10:33 Stefan Agner
  2018-06-27 15:57 ` brcmsmac: " Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Agner @ 2018-06-17 10:33 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Stefan Agner, Tobias Regnery, Arend van Spriel, Franky Lin,
	Hante Meuleman, Chi-Hsien Lin, Wright Feng, David S. Miller,
	linux-wireless, brcm80211-dev-list.pdl, brcm80211-dev-list,
	netdev, linux-kernel

The last value in the log_table wraps around to a negative value
since s16 has a value range of -32768 to 32767. This is not what
the table intends to represent. Use the closest positive value
32767.

This fixes a warning seen with clang:
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_qmath.c:216:2: warning:
      implicit conversion from 'int' to 's16' (aka 'short') changes
value from 32768
      to -32768 [-Wconstant-conversion]
        32768
        ^~~~~
1 warning generated.

Fixes: 4c0bfeaae9f9 ("brcmsmac: fix array out-of-bounds access in qm_log10")
Cc: Tobias Regnery <tobias.regnery@gmail.com>
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
 .../net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_qmath.c    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_qmath.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_qmath.c
index b9672da24a9d..b24bc57ca91b 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_qmath.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_qmath.c
@@ -213,7 +213,7 @@ static const s16 log_table[] = {
 	30498,
 	31267,
 	32024,
-	32768
+	32767
 };
 
 #define LOG_TABLE_SIZE 32       /* log_table size */
-- 
2.17.1


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

* Re: brcmsmac: fix wrap around in conversion from constant to s16
  2018-06-17 10:33 [PATCH] brcm80211: fix wrap around in conversion from constant to s16 Stefan Agner
@ 2018-06-27 15:57 ` Kalle Valo
  0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2018-06-27 15:57 UTC (permalink / raw)
  To: Stefan Agner
  Cc: Stefan Agner, Tobias Regnery, Arend van Spriel, Franky Lin,
	Hante Meuleman, Chi-Hsien Lin, Wright Feng, David S. Miller,
	linux-wireless, brcm80211-dev-list.pdl, brcm80211-dev-list,
	netdev, linux-kernel

Stefan Agner <stefan@agner.ch> wrote:

> The last value in the log_table wraps around to a negative value
> since s16 has a value range of -32768 to 32767. This is not what
> the table intends to represent. Use the closest positive value
> 32767.
> 
> This fixes a warning seen with clang:
> drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_qmath.c:216:2: warning:
>       implicit conversion from 'int' to 's16' (aka 'short') changes
> value from 32768
>       to -32768 [-Wconstant-conversion]
>         32768
>         ^~~~~
> 1 warning generated.
> 
> Fixes: 4c0bfeaae9f9 ("brcmsmac: fix array out-of-bounds access in qm_log10")
> Cc: Tobias Regnery <tobias.regnery@gmail.com>
> Signed-off-by: Stefan Agner <stefan@agner.ch>

Patch applied to wireless-drivers-next.git, thanks.

c9a61469fc97 brcmsmac: fix wrap around in conversion from constant to s16

-- 
https://patchwork.kernel.org/patch/10468755/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

end of thread, other threads:[~2018-06-27 15:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-17 10:33 [PATCH] brcm80211: fix wrap around in conversion from constant to s16 Stefan Agner
2018-06-27 15:57 ` brcmsmac: " Kalle Valo

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).