diff options
author | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2015-11-07 06:33:25 -0500 |
---|---|---|
committer | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2015-11-09 10:52:56 -0500 |
commit | d56e4f75346933dd2cb11533a668ce883908c859 (patch) | |
tree | 943b7852ed98c6cf34ecf2fcd025f1476d86338a | |
parent | 2e31125c241212e2407d61a2d1cbdad0055a30b0 (diff) |
tpm: fix compat 'ppi' link handling in tpm_chip_register()
__compat_only_sysfs_link_entry_to_kobj() was unconditionally called for
TPM1 chips, which caused crash on Acer C720 laptop where DSM for the
ACPI object did not exist.
There are two reasons for unwanted behavior:
* The code did not check whether
__compat_only_sysfs_link_entry_to_kobj() returned -ENOENT. This is
OK. It just meanst that ppi is not available.
* The code did not clean up properly. Compat link should added only
after all other init is done.
This patch sorts out these issues.
Fixes: 9b774d5cf2db
Reported-by: Jeremiah Mahler <jmmahler@gmail.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jeremiah Mahler <jmmahler@gmail.com>
Acked-by: Peter Huewe <PeterHuewe@gmx.de>
-rw-r--r-- | drivers/char/tpm/tpm-chip.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index a5cdce74adab..45cc39aabeee 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c | |||
@@ -226,14 +226,6 @@ int tpm_chip_register(struct tpm_chip *chip) | |||
226 | if (rc) | 226 | if (rc) |
227 | goto out_err; | 227 | goto out_err; |
228 | 228 | ||
229 | if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) { | ||
230 | rc = __compat_only_sysfs_link_entry_to_kobj(&chip->pdev->kobj, | ||
231 | &chip->dev.kobj, | ||
232 | "ppi"); | ||
233 | if (rc) | ||
234 | goto out_err; | ||
235 | } | ||
236 | |||
237 | /* Make the chip available. */ | 229 | /* Make the chip available. */ |
238 | spin_lock(&driver_lock); | 230 | spin_lock(&driver_lock); |
239 | list_add_tail_rcu(&chip->list, &tpm_chip_list); | 231 | list_add_tail_rcu(&chip->list, &tpm_chip_list); |
@@ -241,6 +233,16 @@ int tpm_chip_register(struct tpm_chip *chip) | |||
241 | 233 | ||
242 | chip->flags |= TPM_CHIP_FLAG_REGISTERED; | 234 | chip->flags |= TPM_CHIP_FLAG_REGISTERED; |
243 | 235 | ||
236 | if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) { | ||
237 | rc = __compat_only_sysfs_link_entry_to_kobj(&chip->pdev->kobj, | ||
238 | &chip->dev.kobj, | ||
239 | "ppi"); | ||
240 | if (rc && rc != -ENOENT) { | ||
241 | tpm_chip_unregister(chip); | ||
242 | return rc; | ||
243 | } | ||
244 | } | ||
245 | |||
244 | return 0; | 246 | return 0; |
245 | out_err: | 247 | out_err: |
246 | tpm1_chip_unregister(chip); | 248 | tpm1_chip_unregister(chip); |