From: Kent Overstreet Date: Wed, 14 May 2025 14:44:21 +0000 (-0400) Subject: bcachefs: fix can_write_extent() X-Git-Tag: v6.16-rc1~211^2~61 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=648c1142c9f1ad914c9fd79cedbd6b92ac788cd6;p=thirdparty%2Flinux.git bcachefs: fix can_write_extent() Failing to check the return value of bch2_dev_rcu(): we could (technically) race with device removal. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c index c39ea51e9e484..de096ca65b4ba 100644 --- a/fs/bcachefs/data_update.c +++ b/fs/bcachefs/data_update.c @@ -744,7 +744,9 @@ static int can_write_extent(struct bch_fs *c, struct data_update *m) rcu_read_lock(); unsigned nr_replicas = 0, i; for_each_set_bit(i, devs.d, BCH_SB_MEMBERS_MAX) { - struct bch_dev *ca = bch2_dev_rcu(c, i); + struct bch_dev *ca = bch2_dev_rcu_noerror(c, i); + if (!ca) + continue; struct bch_dev_usage usage; bch2_dev_usage_read_fast(ca, &usage);