released mutex lock before returning from error case