Skip to content

Commit de39965

Browse files
author
Kent Overstreet
committed
bcachefs: Fix null ptr deref in bch2_write_endio()
This was previously hard to hit since it requires racing with device removal, but splitting up io_ref uncovered it. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 7f10fde commit de39965

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

fs/bcachefs/io_write.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -697,12 +697,19 @@ static void bch2_write_endio(struct bio *bio)
697697
bch2_account_io_completion(ca, BCH_MEMBER_ERROR_write,
698698
wbio->submit_time, !bio->bi_status);
699699

700-
if (bio->bi_status) {
701-
bch_err_inum_offset_ratelimited(ca,
702-
op->pos.inode,
703-
wbio->inode_offset << 9,
704-
"data write error: %s",
705-
bch2_blk_status_to_str(bio->bi_status));
700+
if (unlikely(bio->bi_status)) {
701+
if (ca)
702+
bch_err_inum_offset_ratelimited(ca,
703+
op->pos.inode,
704+
wbio->inode_offset << 9,
705+
"data write error: %s",
706+
bch2_blk_status_to_str(bio->bi_status));
707+
else
708+
bch_err_inum_offset_ratelimited(c,
709+
op->pos.inode,
710+
wbio->inode_offset << 9,
711+
"data write error: %s",
712+
bch2_blk_status_to_str(bio->bi_status));
706713
set_bit(wbio->dev, op->failed.d);
707714
op->flags |= BCH_WRITE_io_error;
708715
}

0 commit comments

Comments
 (0)