[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180406160541.8188-1-colin.king@canonical.com>
Date: Fri, 6 Apr 2018 17:05:41 +0100
From: Colin King <colin.king@...onical.com>
To: Peter Huewe <peterhuewe@....de>,
Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>,
Jason Gunthorpe <jgg@...pe.ca>, Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-integrity@...r.kernel.org
Cc: kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] tpm: st33zp24: check if chip is null before dereferencing
From: Colin Ian King <colin.king@...onical.com>
Currently chip is being dereferenced by the call to dev_get_drvdata
before it is being null checked, hence we have a potential null
pointer dereference bug. Fix this by only dereferencing it after the
null check.
Detected by CoverityScan, CID#1357806 ("Dereference before null check")
Fixes: 9e0d39d8a6a0 ("tpm: Remove useless priv field in struct tpm_vendor_specific")
Signed-off-by: Colin Ian King <colin.king@...onical.com>
---
drivers/char/tpm/st33zp24/st33zp24.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c
index f95b9c75175b..476865d66a0e 100644
--- a/drivers/char/tpm/st33zp24/st33zp24.c
+++ b/drivers/char/tpm/st33zp24/st33zp24.c
@@ -367,7 +367,7 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)
static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
size_t len)
{
- struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
+ struct st33zp24_dev *tpm_dev;
u32 status, i, size, ordinal;
int burstcnt = 0;
int ret;
@@ -378,6 +378,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
if (len < TPM_HEADER_SIZE)
return -EBUSY;
+ tpm_dev = dev_get_drvdata(&chip->dev);
ret = request_locality(chip);
if (ret < 0)
return ret;
--
2.15.1
Powered by blists - more mailing lists