Skip to content

Commit a0bd30e

Browse files
author
Kent Overstreet
committed
bcachefs: Fix shift greater than integer size
Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent 600b8be commit a0bd30e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/bcachefs/bkey.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,9 @@ int bch2_bkey_format_invalid(struct bch_fs *c,
660660
bch2_bkey_format_field_overflows(f, i)) {
661661
unsigned unpacked_bits = bch2_bkey_format_current.bits_per_field[i];
662662
u64 unpacked_max = ~((~0ULL << 1) << (unpacked_bits - 1));
663-
u64 packed_max = f->bits_per_field[i]
664-
? ~((~0ULL << 1) << (f->bits_per_field[i] - 1))
663+
unsigned packed_bits = min(64, f->bits_per_field[i]);
664+
u64 packed_max = packed_bits
665+
? ~((~0ULL << 1) << (packed_bits - 1))
665666
: 0;
666667

667668
prt_printf(err, "field %u too large: %llu + %llu > %llu",

0 commit comments

Comments
 (0)