summaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorStefan Berger <stefanb@linux.vnet.ibm.com>2016-11-16 14:56:13 +0100
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2016-11-28 00:31:32 +0100
commit005451d44ad46623aac8349df15d7c0d1d8914c1 (patch)
tree517a6c33f47e181253b35bb61772cf01891ce084 /drivers/char
parenttpm: return -ENODEV if np is not set (diff)
downloadlinux-005451d44ad46623aac8349df15d7c0d1d8914c1.tar.xz
linux-005451d44ad46623aac8349df15d7c0d1d8914c1.zip
tpm: Check the bios_dir entry for NULL before accessing it
Check the bios_dir entry for NULL before accessing it. Currently this crashes the driver when a TPM 2 is attached and the entries are NULL. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/tpm/tpm_eventlog.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
index 8ee4ea10714b..34f0921f0203 100644
--- a/drivers/char/tpm/tpm_eventlog.c
+++ b/drivers/char/tpm/tpm_eventlog.c
@@ -449,10 +449,12 @@ void tpm_bios_log_teardown(struct tpm_chip *chip)
* This design ensures that open() either safely gets kref or fails.
*/
for (i = (TPM_NUM_EVENT_LOG_FILES - 1); i >= 0; i--) {
- inode = d_inode(chip->bios_dir[i]);
- inode_lock(inode);
- inode->i_private = NULL;
- inode_unlock(inode);
- securityfs_remove(chip->bios_dir[i]);
+ if (chip->bios_dir[i]) {
+ inode = d_inode(chip->bios_dir[i]);
+ inode_lock(inode);
+ inode->i_private = NULL;
+ inode_unlock(inode);
+ securityfs_remove(chip->bios_dir[i]);
+ }
}
}