summaryrefslogtreecommitdiff
path: root/fs/nfs
diff options
context:
space:
mode:
authorSergey Shtylyov <s.shtylyov@omp.ru>2024-05-10 23:24:04 +0300
committerTrond Myklebust <trond.myklebust@hammerspace.com>2024-05-21 08:34:15 -0400
commit3c0a2e0b0ae661457c8505fecc7be5501aa7a715 (patch)
tree1a7a7a23b684517b38a1f96fb57323423210c09e /fs/nfs
parenta01b077a8743b2ed329c587cf4bbe49682da243f (diff)
nfs: fix undefined behavior in nfs_block_bits()
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: stable@vger.kernel.org Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Reviewed-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/internal.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index dc0693b3d214..9f0f4534744b 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -717,9 +717,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;
}