Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74ea538a authored by Sergey Shtylyov's avatar Sergey Shtylyov Committed by Greg Kroah-Hartman
Browse files

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: stable@vger.kernel.org
Signed-off-by: default avatarSergey Shtylyov <s.shtylyov@omp.ru>
Reviewed-by: default avatarBenjamin Coddington <bcodding@redhat.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2062e3f1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -615,9 +615,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;
	}