Commit 3c72d3ee authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: Fix WARN() in bch2_bkey_pick_read_device()



syzbot discovered that this one is possible: we have pointers, but none
of them are to valid devices.

Reported-by: default avatar <syzbot+336a6e6a2dbb7d4dba9a@syzkaller.appspotmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent af3d4c27
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -310,6 +310,7 @@
	x(BCH_ERR_data_write,		data_write_misaligned)			\
	x(BCH_ERR_decompress,		data_read)				\
	x(BCH_ERR_data_read,		no_device_to_read_from)			\
	x(BCH_ERR_data_read,		no_devices_valid)			\
	x(BCH_ERR_data_read,		data_read_io_err)			\
	x(BCH_ERR_data_read,		data_read_csum_err)			\
	x(BCH_ERR_data_read,		data_read_retry)			\
+5 −2
Original line number Diff line number Diff line
@@ -227,8 +227,11 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k,
	if (have_io_errors)
		return -BCH_ERR_data_read_io_err;

	WARN_ONCE(1, "unhandled error case in %s\n", __func__);
	return -EINVAL;
	/*
	 * If we get here, we have pointers (bkey_ptrs_validate() ensures that),
	 * but they don't point to valid devices:
	 */
	return -BCH_ERR_no_devices_valid;
}

/* KEY_TYPE_btree_ptr: */