btrfs-progs: chunk-recover: handle duplicate cache entries

Triggered by fuzzed image bko-155621-bad-block-group-offset.raw .

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2016-10-03 15:49:45 +02:00
parent 9adce1abe4
commit 61d5425fd3

View file

@ -2250,6 +2250,13 @@ static int btrfs_recover_chunks(struct recover_control *rc)
chunk->sub_stripes = calc_sub_nstripes(bg->flags);
ret = insert_cache_extent(&rc->chunk, &chunk->cache);
if (ret == -EEXIST) {
error("duplicate entry in cache start %llu size %llu",
(unsigned long long)chunk->cache.start,
(unsigned long long)chunk->cache.size);
free(chunk);
return ret;
}
BUG_ON(ret);
list_del_init(&bg->list);