Skip to content

Commit

Permalink
tpm: Check the bios_dir entry for NULL before accessing it
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stefan Berger authored and Jarkko Sakkinen committed Nov 27, 2016
1 parent 79eec5b commit 005451d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/char/tpm/tpm_eventlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}

0 comments on commit 005451d

Please sign in to comment.