summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorLiu Bo <bo.li.liu@oracle.com>2016-07-05 15:10:14 -0400
committerDavid Sterba <dsterba@suse.com>2016-07-26 07:52:25 -0400
commitfb770ae414d018255afa7a70b14ba1f8620762dd (patch)
treece23654b16f7de208bb88096b2c0f9208c4a5eca /fs/btrfs/tree-log.c
parent876d2cf141b42f9be70a383502a324b64b23f33a (diff)
Btrfs: fix read_node_slot to return errors
We use read_node_slot() to read btree node and it has two cases, a) slot is out of range, which means 'no such entry' b) we fail to read the block, due to checksum fails or corrupted content or not with uptodate flag. But we're returning NULL in both cases, this makes it return -ENOENT in case a) and return -EIO in case b), and this fixes its callers as well as btrfs_search_forward() 's caller to catch the new errors. The problem is reported by Peter Becker, and I can manage to hit the same BUG_ON by mounting my fuzz image. Reported-by: Peter Becker <floyd.net@gmail.com> Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index c05f69a8ec42..aa4475e3046b 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -4703,6 +4703,10 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
4703 ins_nr = 0; 4703 ins_nr = 0;
4704 ret = btrfs_search_forward(root, &min_key, 4704 ret = btrfs_search_forward(root, &min_key,
4705 path, trans->transid); 4705 path, trans->transid);
4706 if (ret < 0) {
4707 err = ret;
4708 goto out_unlock;
4709 }
4706 if (ret != 0) 4710 if (ret != 0)
4707 break; 4711 break;
4708again: 4712again: