]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Fix a null ptr deref
authorKent Overstreet <kent.overstreet@gmail.com>
Sat, 7 Sep 2019 17:16:41 +0000 (13:16 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:26 +0000 (17:08 -0400)
rbio->c wasn't being initialized in the move path

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

index 844ae46cd7ebb86c21a83db6af222520d9f23b48..b0bff54a18e296ea811fb83e4a3755c1f90c7b6c 100644 (file)
@@ -1218,10 +1218,15 @@ static inline struct bch_read_bio *bch2_rbio_free(struct bch_read_bio *rbio)
        return rbio;
 }
 
+/*
+ * Only called on a top level bch_read_bio to complete an entire read request,
+ * not a split:
+ */
 static void bch2_rbio_done(struct bch_read_bio *rbio)
 {
-       bch2_time_stats_update(&rbio->c->times[BCH_TIME_data_read],
-                              rbio->start_time);
+       if (rbio->start_time)
+               bch2_time_stats_update(&rbio->c->times[BCH_TIME_data_read],
+                                      rbio->start_time);
        bio_endio(&rbio->bio);
 }
 
index 05bb74a36230b419630f8707d77aa58bbbc94f2d..d01c96ff00d7bfc84f2c44be6e4a18b69479f35d 100644 (file)
@@ -436,7 +436,8 @@ static int bch2_move_extent(struct bch_fs *c,
                                 GFP_KERNEL))
                goto err_free;
 
-       io->rbio.opts = io_opts;
+       io->rbio.c              = c;
+       io->rbio.opts           = io_opts;
        bio_init(&io->rbio.bio, NULL, io->bi_inline_vecs, pages, 0);
        io->rbio.bio.bi_vcnt = pages;
        bio_set_prio(&io->rbio.bio, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0));