Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

omfs: fix potential integer overflow in allocator

Both 'i' and 'bits_per_entry' are signed integers but the result is a
u64 block number. Cast i to u64 to avoid truncation on 32-bit targets.

Found by Coverity (CID 200679).

Signed-off-by: Bob Copeland <me@bobcopeland.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Bob Copeland and committed by
Linus Torvalds
5a6b2b36 c0345ee5

+1 -1
+1 -1
fs/omfs/bitmap.c
··· 159 159 goto out; 160 160 161 161 found: 162 - *return_block = i * bits_per_entry + bit; 162 + *return_block = (u64) i * bits_per_entry + bit; 163 163 *return_size = run; 164 164 ret = set_run(sb, i, bits_per_entry, bit, run, 1); 165 165