mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-12-01 16:31:34 -05:00
nfs: fix undefined behavior in nfs_block_bits()
commit 3c0a2e0b0ae661457c8505fecc7be5501aa7a715 upstream. Shifting *signed int* typed constant 1 left by 31 bits causes undefined behavior. Specify the correct *unsigned long* type by using 1UL instead. Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool. Cc: [email protected] Signed-off-by: Sergey Shtylyov <[email protected]> Reviewed-by: Benjamin Coddington <[email protected]> Signed-off-by: Trond Myklebust <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
7c72af16ab
commit
2997e2fb1c
1 changed files with 2 additions and 2 deletions
|
|
@ -609,9 +609,9 @@ unsigned long nfs_block_bits(unsigned long bsize, unsigned char *nrbitsp)
|
|||
if ((bsize & (bsize - 1)) || nrbitsp) {
|
||||
unsigned char nrbits;
|
||||
|
||||
for (nrbits = 31; nrbits && !(bsize & (1 << nrbits)); nrbits--)
|
||||
for (nrbits = 31; nrbits && !(bsize & (1UL << nrbits)); nrbits--)
|
||||
;
|
||||
bsize = 1 << nrbits;
|
||||
bsize = 1UL << nrbits;
|
||||
if (nrbitsp)
|
||||
*nrbitsp = nrbits;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue