TPM_ERROR and ScopedTssType: uses the first, creates the second.
This change fixes two issues:
1. A huge amount of duplicated code during error path handling.
2. Relying on TSS_SUCCESS to be 0 forever.
2 was fixed by using the TPM_ERROR() macro everywhere.
1 is addressed by adding wrappers around all the TSS objects that need
to be freed such that automatic variable scope will result in the
correct releasing of the objects (and in the right order).
My original implementation used one main TSS manager class which
handled the objects and memory. However, ignoring storage class
changes, the destructor ordering in a function should be reliable
to ensure that all TSS objects and memory will be cleaned up
prior to any ScopedTssContexts being destroyed.
Thoughts?
TEST=
1. unittests pass
2. suite_Smoke passes in a VM
3. live test of x86-alex works
4. On booted x86-alex, repeated calls to cryptohome --action=status does not appear to incur any memory leakage. I'll start a longer run.
BUG=chromium-os:13129
Change-Id: I5b0f654cc524fb4fee4f909a4d7d4c9754595c69
R=gauravsh@chromium.org,fes@chromium.org
Review URL: http://codereview.chromium.org/6683071
3 files changed