From: Colin Ian King Date: Tue, 15 Jan 2019 18:03:38 +0000 (+0000) Subject: atm: he: fix sign-extension overflow on large shift X-Git-Tag: v4.19.26~67 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e0d7b0a2a57adbd0f33a280f6628a9c4d7a87c92;p=platform%2Fkernel%2Flinux-rpi.git atm: he: fix sign-extension overflow on large shift [ Upstream commit cb12d72b27a6f41325ae23a11033cf5fedfa1b97 ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- diff --git a/drivers/atm/he.c b/drivers/atm/he.c index 29f102d..329ce90 100644 --- a/drivers/atm/he.c +++ b/drivers/atm/he.c @@ -717,7 +717,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 */