Fixed error and return code.
Fixed error and return code.

Reviewed-by: Matt Caswell <1fa2ef4755a9226cb9a0a4840bd89b158ac71391@openssl.org>
Reviewed-by: Tomas Mraz <973cc78d8b4cb00714230ba9be0225e917ab4ac6@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12100)

openssl/openssl,openssl/openssl,openssl/openssl,openssl/openssl,openssl/openssl,openssl/openssl