From 75923ba7ad56f7236ae3979577011f5220d07d50 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sat, 4 Apr 2020 13:54:19 -0400 Subject: [PATCH] bcachefs: Fix a null ptr deref during journal replay We were calling bch2_extent_can_insert() incorrectly; it should only be called when the extents-to-keys pass is running because that's when we could be splitting a compressed extent. Calling bch2_extent_can_insert() without passing in a disk reservation was causing a null ptr deref. Signed-off-by: Kent Overstreet Signed-off-by: Kent Overstreet --- fs/bcachefs/btree_update_leaf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 1e6675f68b4ac..b9283ced4cae6 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -309,7 +309,7 @@ btree_key_can_insert(struct btree_trans *trans, if (unlikely(btree_node_old_extent_overwrite(b))) return BTREE_INSERT_BTREE_NODE_FULL; - ret = !btree_node_is_extents(b) + ret = !(iter->flags & BTREE_ITER_IS_EXTENTS) ? BTREE_INSERT_OK : bch2_extent_can_insert(trans, iter, insert); if (ret) -- 2.30.2