In the "while(!mdrestore.error) {}" loop if we got a bad header or
add_cluster() failed, we break the loop.
But immediately after breaking out the loop, we call wait_for_worker(),
which overwrites @ret, and also continue to open_ctree().
Fix the problem by directly jumping to out label.
Also for bad header case, update the error code to -EUCLEAN.
Assisted-by: LLM (exposing the bug)
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
if (get_unaligned_le64(&header->magic) != current_version->magic_cpu ||
get_unaligned_le64(&header->bytenr) != bytenr) {
error("bad header in metadump image");
- ret = -EIO;
- break;
+ ret = -EUCLEAN;
+ goto out;
}
ret = add_cluster(cluster, &mdrestore, &bytenr);
if (ret) {
error("failed to add cluster: %d", ret);
- break;
+ goto out;
}
}
ret = wait_for_worker(&mdrestore);