diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-10-02 15:14:32 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:08:28 +0200 |
commit | 618b9e575b40c862a62764043c961646f3ebc6dc (patch) | |
tree | 4513da60eed83c85bbc98ad473793de5a8111cda | |
parent | bcachefs: Fix an error path (diff) | |
download | linux-618b9e575b40c862a62764043c961646f3ebc6dc.tar.xz linux-618b9e575b40c862a62764043c961646f3ebc6dc.zip |
bcachefs: Fix undefined behaviour
roundup_pow_of_two(0) is undefined
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/ec.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 155e7c9bd89f..424d5cf48893 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -1351,6 +1351,9 @@ int bch2_ec_mem_alloc(struct bch_fs *c, bool gc) if (ret) return ret; + if (!idx) + return 0; + if (!gc && !init_heap(&c->ec_stripes_heap, roundup_pow_of_two(idx), GFP_KERNEL)) |