May I ask what level is the sub-domain, if the sub-domain is like sub.domain.com or rather like www.sub.domain.com?
Before adding a DNS hostname to the DNS tab of Cloudflare dashboard for your domain name, was the particular sub-domain working over HTTPS connection and have had provisioned a valid SSL certificate?
May I ask what SSL option have you got selected under the SSL/TLS tab at Cloudflare dashboard for your domain ( Flexible, Full, Full Strict … )?
Regarding SSL issues with sub-domains:
Regarding Cloudflare 522 error, may I suggest you to look into below article to troubleshoot the issue (if already not yet):