From f516c87272c98186f12768e9589664ce7a910bf4 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Thu, 11 Jul 2019 12:45:59 -0400 Subject: [PATCH] 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 --- fs/bcachefs/ec.c | 3 ++- fs/bcachefs/super.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 6d59631b8259b..42bca2b413e3f 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, diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 91562b95bd973..202c0b443ef48 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -277,6 +277,7 @@ void bch2_fs_read_only(struct bch_fs *c) */ percpu_ref_kill(&c->writes); + cancel_work_sync(&c->ec_stripe_delete_work); cancel_delayed_work(&c->pd_controllers_update); /* -- 2.30.2