Rework error handling from asn1_do_lock method.