bcachefs: Fix an out-of-bounds shift

roundup_pow_of_two() is undefined for 0 - oops.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet
2022-10-22 16:19:27 -04:00
parent df6a24f81a
commit 1f69368c5c

View File

@@ -2879,7 +2879,7 @@ void __bch2_trans_init(struct btree_trans *trans, struct bch_fs *c, unsigned fn_
bch2_trans_alloc_paths(trans, c);
s = btree_trans_stats(trans);
if (s) {
if (s && s->max_mem) {
unsigned expected_mem_bytes = roundup_pow_of_two(s->max_mem);
trans->mem = kmalloc(expected_mem_bytes, GFP_KERNEL);
@@ -2890,9 +2890,9 @@ void __bch2_trans_init(struct btree_trans *trans, struct bch_fs *c, unsigned fn_
} else {
trans->mem_bytes = expected_mem_bytes;
}
trans->nr_max_paths = s->nr_max_paths;
}
if (s)
trans->nr_max_paths = s->nr_max_paths;
trans->srcu_idx = srcu_read_lock(&c->btree_trans_barrier);