Commit 1f69368c authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Fix an out-of-bounds shift

roundup_pow_of_two() is undefined for 0 - oops.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent df6a24f8
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment