Selaa lähdekoodia

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>
Stefan Berger 8 vuotta sitten
vanhempi
commit
005451d44a
1 muutettua tiedostoa jossa 7 lisäystä ja 5 poistoa
  1. 7 5
      drivers/char/tpm/tpm_eventlog.c

+ 7 - 5
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.
 	 * This design ensures that open() either safely gets kref or fails.
 	 */
 	 */
 	for (i = (TPM_NUM_EVENT_LOG_FILES - 1); i >= 0; i--) {
 	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]);
+		}
 	}
 	}
 }
 }