Skip to contentSkip to conversation

tpm: Add explicit chip->ops locking for sysfs attributes.

PATCH In review Guenter Roeck 2 participants 2 messages Nov 16, 2017 – Nov 17, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tpm: Add explicit chip->ops locking for sysfs attributes.

Add explicit chip->ops locking for all sysfs attributes. This lets us support those attributes on tpm2 devices.

---
v2: It makes sense to actually compile the code.

 drivers/char/tpm/tpm-chip.c  |   4 --
 drivers/char/tpm/tpm-sysfs.c | 127 ++++++++++++++++++++++++++++++++-----------
 2 files changed, 94 insertions(+), 37 deletions(-)
drivers/char/tpm/tpm-chip.c +0 -4
index 0eca20c5a80c..f0593ec1c11b 100644
@@ -149,10 +149,6 @@ static void tpm_devs_release(struct device *dev)
  * Issues a TPM2_Shutdown command prior to loss of power, as required by the
  * TPM 2.0 spec.
  * Then, calls bus- and device- specific shutdown code.
- *
- * XXX: This codepath relies on the fact that sysfs is not enabled for
- * TPM2: sysfs uses an implicit lock on chip->ops, so this could race if TPM2
- * has sysfs support enabled before TPM sysfs's implicit locking is fixed.
  */
 static int tpm_class_shutdown(struct device *dev)
 {
drivers/char/tpm/tpm-sysfs.c +94 -33

253 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw
Quoted 9 lines · Guenter Roeck

Add explicit chip->ops locking for all sysfs attributes. This lets us support those attributes on tpm2 devices.

v2: It makes sense to actually compile the code.

 drivers/char/tpm/tpm-chip.c  |   4 --
 drivers/char/tpm/tpm-sysfs.c | 127 ++++++++++++++++++++++++++++++++-----------
 2 files changed, 94 insertions(+), 37 deletions(-)

I haven't exhaustively checked this, but as the originator of the comment, this looks broadly like the right approach to me.

Cheers,
Jason