bcachefs: Fix stripe_idx_to_delete()
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 11 Jul 2019 16:45:59 +0000 (12:45 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:24 +0000 (17:08 -0400)
There was a null ptr deref when there wasn't a stripes heap allocated

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/ec.c
fs/bcachefs/super.c

index 6d59631b8259b8dc2cae74d875511f678e02be90..42bca2b413e3f37e27bff758a829033f1c7b071b 100644 (file)
@@ -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,
index 91562b95bd9737ba5947d8f60e1218ede19bfb9b..202c0b443ef48bd821d79ab11b29ae89ff1609e6 100644 (file)
@@ -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);
 
        /*