From: Kent Overstreet Date: Wed, 2 Oct 2019 13:14:32 +0000 (-0400) Subject: bcachefs: Fix undefined behaviour X-Git-Tag: v6.7-rc1~201^2~2321 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=618b9e575b40c862a62764043c961646f3ebc6dc;p=thirdparty%2Flinux.git bcachefs: Fix undefined behaviour roundup_pow_of_two(0) is undefined Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 155e7c9bd89fe..424d5cf48893a 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))