Skip to contentSkip to conversation

tpm: suppress durations sysfs output if not read

PATCH In review Stefan Berger 2 participants 2 messages Aug 23, 2011 TPM device driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: suppress durations sysfs output if not read

Suppress the output in the 'durations' sysfs entry if they were not read during driver initialization. This is similar to other sysfs entries that return nothing if for some reason sending the commands to the TPM fails.

---
 drivers/char/tpm/tpm.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/char/tpm/tpm.c +3 -0
Index: linux-2.6/drivers/char/tpm/tpm.c
===================================================================
@@ -963,6 +963,9 @@ ssize_t tpm_show_durations(struct device
 {
 	struct tpm_chip *chip = dev_get_drvdata(dev);
 
+	if (chip->vendor.duration[TPM_LONG] == 0)
+		return 0;
+
 	return sprintf(buf, "%d %d %d [%s]\n",
 		       jiffies_to_usecs(chip->vendor.duration[TPM_SHORT]),
 		       jiffies_to_usecs(chip->vendor.duration[TPM_MEDIUM]),
#1 lore raw
Quoted 6 lines · Stefan Berger

Suppress the output in the 'durations' sysfs entry if they were not read during driver initialization. This is similar to other sysfs entries that return nothing if for some reason sending the commands to the TPM fails.

Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next

Quoted 20 lines
---
 drivers/char/tpm/tpm.c |    3 +++
 1 file changed, 3 insertions(+)

Index: linux-2.6/drivers/char/tpm/tpm.c
===================================================================

drivers/char/tpm/tpm.c +3 -0
@@ -963,6 +963,9 @@ ssize_t tpm_show_durations(struct device
 {
 	struct tpm_chip *chip = dev_get_drvdata(dev);
 
+	if (chip->vendor.duration[TPM_LONG] == 0)
+		return 0;
+
 	return sprintf(buf, "%d %d %d [%s]\n",
 		       jiffies_to_usecs(chip->vendor.duration[TPM_SHORT]),
 		       jiffies_to_usecs(chip->vendor.duration[TPM_MEDIUM]),
Signature · 2 lines
James Morris
<[email protected]>