summaryrefslogtreecommitdiff
path: root/fs/bcachefs/ec.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-07-11 19:45:59 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:08:24 +0300
commitf516c87272c98186f12768e9589664ce7a910bf4 (patch)
tree2b549b7b11d75d9543d6b056f7eec5094c2606d2 /fs/bcachefs/ec.c
parent97fd13ad769c24260ce0e05f05a51df132b980bd (diff)
downloadlinux-f516c87272c98186f12768e9589664ce7a910bf4.tar.xz
bcachefs: Fix stripe_idx_to_delete()
There was a null ptr deref when there wasn't a stripes heap allocated Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/ec.c')
-rw-r--r--fs/bcachefs/ec.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 6d59631b8259..42bca2b413e3 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -575,7 +575,8 @@ static ssize_t stripe_idx_to_delete(struct bch_fs *c)
{
ec_stripes_heap *h = &c->ec_stripes_heap;
- return h->data[0].blocks_nonempty == 0 ? h->data[0].idx : -1;
+ return h->used && h->data[0].blocks_nonempty == 0
+ ? h->data[0].idx : -1;
}
static inline int ec_stripes_heap_cmp(ec_stripes_heap *h,