@@ -353,18 +353,26 @@ int tpm_chip_register(struct tpm_chip *chip)
tpm_add_ppi(chip);
rc = tpm_add_char_device(chip);
- if (rc) {
- tpm_bios_log_teardown(chip);
- return rc;
- }
+ if (rc)
+ goto err_add_char;
+
+ rc = tpm_add_rm_char_device(chip);
+ if (rc)
+ goto err_add_rm_char;
rc = tpm_add_legacy_sysfs(chip);
- if (rc) {
- tpm_chip_unregister(chip);
- return rc;
- }
+ if (rc)
+ goto err_add_legacy_sysfs;
return 0;
+
+err_add_legacy_sysfs:
+ tpm_del_rm_char_device(chip);
+err_add_rm_char:
+ tpm_del_char_device(chip, true);
+err_add_char:
+ tpm_bios_log_teardown(chip);
+ return rc;
}
EXPORT_SYMBOL_GPL(tpm_chip_register);
@@ -384,6 +392,7 @@ EXPORT_SYMBOL_GPL(tpm_chip_register);
void tpm_chip_unregister(struct tpm_chip *chip)
{
tpm_del_legacy_sysfs(chip);
+ tpm_del_rm_char_device(chip);
tpm_bios_log_teardown(chip);
tpm_del_char_device(chip, true);
}