aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-07-11 12:45:59 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:24 -0400
commitf516c87272c98186f12768e9589664ce7a910bf4 (patch)
tree2b549b7b11d75d9543d6b056f7eec5094c2606d2
parent97fd13ad769c24260ce0e05f05a51df132b980bd (diff)
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>
-rw-r--r--fs/bcachefs/ec.c3
-rw-r--r--fs/bcachefs/super.c1
2 files changed, 3 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,
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index 91562b95bd97..202c0b443ef4 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);
/*