From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jarkko Sakkinen Subject: Re: [PATCH] tpm: Check the bios_dir entry for NULL before accessing it Date: Wed, 16 Nov 2016 07:38:38 -0800 Message-ID: <20161116153838.duyh3arvarzyupgv@intel.com> References: <1479304573-13601-1-git-send-email-stefanb@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1479304573-13601-1-git-send-email-stefanb-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Stefan Berger Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: tpmdd-devel@lists.sourceforge.net On Wed, Nov 16, 2016 at 08:56:13AM -0500, Stefan Berger wrote: > 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 Reviewed-by: Jarkko Sakkinen > --- > 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 /Jarkko ------------------------------------------------------------------------------