summaryrefslogtreecommitdiffstats
path: root/drivers/atm/he.c
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2019-01-15 19:03:38 +0100
committerDavid S. Miller <davem@davemloft.net>2019-01-17 20:27:00 +0100
commitcb12d72b27a6f41325ae23a11033cf5fedfa1b97 (patch)
tree766c9eab37443392f4603bc802e8fe88c960830f /drivers/atm/he.c
parentudp: with udp_segment release on error path (diff)
downloadlinux-cb12d72b27a6f41325ae23a11033cf5fedfa1b97.tar.xz
linux-cb12d72b27a6f41325ae23a11033cf5fedfa1b97.zip
atm: he: fix sign-extension overflow on large shift
Shifting the 1 by exp by an int can lead to sign-extension overlow when exp is 31 since 1 is an signed int and sign-extending this result to an unsigned long long will set the upper 32 bits. Fix this by shifting an unsigned long. Detected by cppcheck: (warning) Shifting signed 32-bit value by 31 bits is undefined behaviour Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/atm/he.c')
-rw-r--r--drivers/atm/he.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index 2e9d1cfe3aeb..211607986134 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -718,7 +718,7 @@ static int he_init_cs_block_rcm(struct he_dev *he_dev)
instead of '/ 512', use '>> 9' to prevent a call
to divdu3 on x86 platforms
*/
- rate_cps = (unsigned long long) (1 << exp) * (man + 512) >> 9;
+ rate_cps = (unsigned long long) (1UL << exp) * (man + 512) >> 9;
if (rate_cps < 10)
rate_cps = 10; /* 2.2.1 minimum payload rate is 10 cps */