tpm.c: fix crash during device removal