tpm: fix double write race and tpm_release free issue