From fd1e9ad6a89b9b24a601d85b68c7a616f63ef0a7 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Sat, 3 Jan 2015 02:47:32 +0100 Subject: [PATCH] btrfs-progs: check, handle error in fix_key_order In case the buffer is corrupted and the for loop does not happen, we'd return garbage. The caller retunrs -EIO in case of any corruption, use that value in fix_key_order. Resolves-coverity-id: 1246944 Signed-off-by: David Sterba --- cmds-check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds-check.c b/cmds-check.c index d2d218a..6c87d1a 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -3468,7 +3468,7 @@ static int fix_key_order(struct btrfs_trans_handle *trans, struct btrfs_key k1, k2; int i; int level = path->lowest_level; - int ret; + int ret = -EIO; buf = path->nodes[level]; for (i = 0; i < btrfs_header_nritems(buf) - 1; i++) { -- 2.7.4