* [PATCH][next] rtw88: fix shift of more than 32 bits of a integer
@ 2019-05-01 14:19 Colin King
2019-05-02 14:58 ` Kalle Valo
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-05-01 14:19 UTC (permalink / raw)
To: Yan-Hsuan Chuang, Kalle Valo, David S . Miller, linux-wireless,
netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently the shift of an integer value more than 32 bits can
occur when nss is more than 32. Fix this by making the integer
constants unsigned long longs before shifting and bit-wise or'ing
with the u64 ra_mask to avoid the undefined shift behaviour.
Addresses-Coverity: ("Bad shift operation")
Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/wireless/realtek/rtw88/main.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
index 9893e5e297e3..6304082361a7 100644
--- a/drivers/net/wireless/realtek/rtw88/main.c
+++ b/drivers/net/wireless/realtek/rtw88/main.c
@@ -363,13 +363,13 @@ static u64 get_vht_ra_mask(struct ieee80211_sta *sta)
vht_mcs_cap = mcs_map & 0x3;
switch (vht_mcs_cap) {
case 2: /* MCS9 */
- ra_mask |= 0x3ff << nss;
+ ra_mask |= 0x3ffULL << nss;
break;
case 1: /* MCS8 */
- ra_mask |= 0x1ff << nss;
+ ra_mask |= 0x1ffULL << nss;
break;
case 0: /* MCS7 */
- ra_mask |= 0x0ff << nss;
+ ra_mask |= 0x0ffULL << nss;
break;
default:
break;
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][next] rtw88: fix shift of more than 32 bits of a integer
2019-05-01 14:19 [PATCH][next] rtw88: fix shift of more than 32 bits of a integer Colin King
@ 2019-05-02 14:58 ` Kalle Valo
0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2019-05-02 14:58 UTC (permalink / raw)
To: Colin King
Cc: Yan-Hsuan Chuang, David S . Miller, linux-wireless, netdev,
kernel-janitors, linux-kernel
Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the shift of an integer value more than 32 bits can
> occur when nss is more than 32. Fix this by making the integer
> constants unsigned long longs before shifting and bit-wise or'ing
> with the u64 ra_mask to avoid the undefined shift behaviour.
>
> Addresses-Coverity: ("Bad shift operation")
> Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Patch applied to wireless-drivers-next.git, thanks.
b85bd9a14c4b rtw88: fix shift of more than 32 bits of a integer
--
https://patchwork.kernel.org/patch/10925147/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-02 14:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-01 14:19 [PATCH][next] rtw88: fix shift of more than 32 bits of a integer Colin King
2019-05-02 14:58 ` 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).