check_parent_exists() can change errno. Ensure we preserve it across calls.