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 <dsterba@suse.cz>
This commit is contained in:
David Sterba 2015-01-03 02:47:32 +01:00
parent de5c542275
commit fd1e9ad6a8

View File

@ -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++) {