linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tpm_tis: extra chip->ops check on error path in tpm_tis_core_init
@ 2020-06-13 14:18 Vasily Averin
  2020-06-17  2:10 ` Jarkko Sakkinen
  2020-06-17  2:26 ` Jerry Snitselaar
  0 siblings, 2 replies; 4+ messages in thread
From: Vasily Averin @ 2020-06-13 14:18 UTC (permalink / raw)
  To: linux-integrity; +Cc: Jarkko Sakkinen, Peter Huewe, Jason Gunthorpe

Found by smatch:
drivers/char/tpm/tpm_tis_core.c:1088 tpm_tis_core_init() warn:
 variable dereferenced before check 'chip->ops' (see line 979)

'chip->ops' is assigned in the beginning of function
in tpmm_chip_alloc->tpm_chip_alloc
and is used before first possible goto to error path.

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 drivers/char/tpm/tpm_tis_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 2435216..65ab1b0 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -1085,7 +1085,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 
 	return 0;
 out_err:
-	if ((chip->ops != NULL) && (chip->ops->clk_enable != NULL))
+	if (chip->ops->clk_enable != NULL)
 		chip->ops->clk_enable(chip, false);
 
 	tpm_tis_remove(chip);
-- 
1.8.3.1


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

* Re: [PATCH] tpm_tis: extra chip->ops check on error path in tpm_tis_core_init
  2020-06-13 14:18 [PATCH] tpm_tis: extra chip->ops check on error path in tpm_tis_core_init Vasily Averin
@ 2020-06-17  2:10 ` Jarkko Sakkinen
  2020-06-17  2:26 ` Jerry Snitselaar
  1 sibling, 0 replies; 4+ messages in thread
From: Jarkko Sakkinen @ 2020-06-17  2:10 UTC (permalink / raw)
  To: Vasily Averin; +Cc: linux-integrity, Peter Huewe, Jason Gunthorpe

On Sat, Jun 13, 2020 at 05:18:33PM +0300, Vasily Averin wrote:
> Found by smatch:
> drivers/char/tpm/tpm_tis_core.c:1088 tpm_tis_core_init() warn:
>  variable dereferenced before check 'chip->ops' (see line 979)
> 
> 'chip->ops' is assigned in the beginning of function
> in tpmm_chip_alloc->tpm_chip_alloc
> and is used before first possible goto to error path.
> 
> Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
 
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

/Jarkko

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

* Re: [PATCH] tpm_tis: extra chip->ops check on error path in tpm_tis_core_init
  2020-06-13 14:18 [PATCH] tpm_tis: extra chip->ops check on error path in tpm_tis_core_init Vasily Averin
  2020-06-17  2:10 ` Jarkko Sakkinen
@ 2020-06-17  2:26 ` Jerry Snitselaar
  2020-06-17 23:29   ` Jarkko Sakkinen
  1 sibling, 1 reply; 4+ messages in thread
From: Jerry Snitselaar @ 2020-06-17  2:26 UTC (permalink / raw)
  To: Vasily Averin
  Cc: linux-integrity, Jarkko Sakkinen, Peter Huewe, Jason Gunthorpe

On Sat Jun 13 20, Vasily Averin wrote:
>Found by smatch:
>drivers/char/tpm/tpm_tis_core.c:1088 tpm_tis_core_init() warn:
> variable dereferenced before check 'chip->ops' (see line 979)
>
>'chip->ops' is assigned in the beginning of function
>in tpmm_chip_alloc->tpm_chip_alloc
>and is used before first possible goto to error path.
>
>Signed-off-by: Vasily Averin <vvs@virtuozzo.com>

Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>

>---
> drivers/char/tpm/tpm_tis_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
>index 2435216..65ab1b0 100644
>--- a/drivers/char/tpm/tpm_tis_core.c
>+++ b/drivers/char/tpm/tpm_tis_core.c
>@@ -1085,7 +1085,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
>
> 	return 0;
> out_err:
>-	if ((chip->ops != NULL) && (chip->ops->clk_enable != NULL))
>+	if (chip->ops->clk_enable != NULL)
> 		chip->ops->clk_enable(chip, false);
>
> 	tpm_tis_remove(chip);
>-- 
>1.8.3.1
>


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

* Re: [PATCH] tpm_tis: extra chip->ops check on error path in tpm_tis_core_init
  2020-06-17  2:26 ` Jerry Snitselaar
@ 2020-06-17 23:29   ` Jarkko Sakkinen
  0 siblings, 0 replies; 4+ messages in thread
From: Jarkko Sakkinen @ 2020-06-17 23:29 UTC (permalink / raw)
  To: Jerry Snitselaar
  Cc: Vasily Averin, linux-integrity, Peter Huewe, Jason Gunthorpe

On Tue, Jun 16, 2020 at 07:26:32PM -0700, Jerry Snitselaar wrote:
> On Sat Jun 13 20, Vasily Averin wrote:
> > Found by smatch:
> > drivers/char/tpm/tpm_tis_core.c:1088 tpm_tis_core_init() warn:
> > variable dereferenced before check 'chip->ops' (see line 979)
> > 
> > 'chip->ops' is assigned in the beginning of function
> > in tpmm_chip_alloc->tpm_chip_alloc
> > and is used before first possible goto to error path.
> > 
> > Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
> 
> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>

Thanks, I added this to the commit.

/Jarkko

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

end of thread, other threads:[~2020-06-17 23:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-13 14:18 [PATCH] tpm_tis: extra chip->ops check on error path in tpm_tis_core_init Vasily Averin
2020-06-17  2:10 ` Jarkko Sakkinen
2020-06-17  2:26 ` Jerry Snitselaar
2020-06-17 23:29   ` Jarkko Sakkinen

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).