tpmdd-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] tpm: Check the bios_dir entry for NULL before accessing it
@ 2016-11-16 13:56 Stefan Berger
       [not found] ` <1479304573-13601-1-git-send-email-stefanb-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Berger @ 2016-11-16 13:56 UTC (permalink / raw)
  To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA,
	tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	nayna-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8

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-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
---
 drivers/char/tpm/tpm_eventlog.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
index ebec4ac..fb603a7 100644
--- a/drivers/char/tpm/tpm_eventlog.c
+++ b/drivers/char/tpm/tpm_eventlog.c
@@ -455,10 +455,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]);
+		}
 	}
 }
-- 
2.4.3


------------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-11-16 23:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-16 13:56 [PATCH] tpm: Check the bios_dir entry for NULL before accessing it Stefan Berger
     [not found] ` <1479304573-13601-1-git-send-email-stefanb-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2016-11-16 14:58   ` Nayna
     [not found]     ` <582C7416.7090105-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2016-11-16 15:40       ` Jarkko Sakkinen
     [not found]         ` <20161116154027.i6rtsl2mendbb4ce-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-11-16 15:49           ` Stefan Berger
     [not found]             ` <f4a7d9a4-c832-fd06-6a62-7b800f42585f-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2016-11-16 17:57               ` Jarkko Sakkinen
2016-11-16 15:38   ` Jarkko Sakkinen
2016-11-16 20:38   ` Jason Gunthorpe
     [not found]     ` <20161116203853.GA22708-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-11-16 22:06       ` Jarkko Sakkinen
     [not found]         ` <20161116220633.yfvpnvps3e222527-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-11-16 22:08           ` Jarkko Sakkinen
2016-11-16 23:56           ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).