Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 005451d4 authored by Stefan Berger's avatar Stefan Berger Committed by Jarkko Sakkinen
Browse files

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: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
parent 79eec5b9
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -449,6 +449,7 @@ 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--) {
		if (chip->bios_dir[i]) {
			inode = d_inode(chip->bios_dir[i]);
			inode_lock(inode);
			inode->i_private = NULL;
@@ -456,3 +457,4 @@ void tpm_bios_log_teardown(struct tpm_chip *chip)
			securityfs_remove(chip->bios_dir[i]);
		}
	}
}