Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1653679 > unrolled thread
| Started by | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| First post | 2017-05-31 00:20 +0200 |
| Last post | 2017-05-31 02:10 +0200 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] char: tpm: fix potential null pointer dereference "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-05-31 00:20 +0200
Re: [PATCH] char: tpm: fix potential null pointer dereference Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-05-31 00:30 +0200
Re: [PATCH] char: tpm: fix potential null pointer dereference "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-05-31 00:50 +0200
[PATCH] char: tpm: remove unnecessary code "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-05-31 02:10 +0200
| From | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| Date | 2017-05-31 00:20 +0200 |
| Subject | [PATCH] char: tpm: fix potential null pointer dereference |
| Message-ID | <tMXEC-4Ei-13@gated-at.bofh.it> |
NULL check at line 376: if (!chip) {, implies chip might be NULL.
Function dev_get_drvdata() dereference pointer chip.
Move pointer tmp_dev assignment after the NULL check.
Addresses-Coverity-ID: 1397648
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.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 4d1dc8b..f45e8c7 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;
@@ -382,6 +382,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
if (ret < 0)
return ret;
+ tpm_dev = dev_get_drvdata(&chip->dev);
status = st33zp24_status(chip);
if ((status & TPM_STS_COMMAND_READY) == 0) {
st33zp24_cancel(chip);
--
2.5.0
[toc] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2017-05-31 00:30 +0200 |
| Message-ID | <tMXOi-4I0-15@gated-at.bofh.it> |
| In reply to | #1653679 |
On Tue, May 30, 2017 at 05:05:20PM -0500, Gustavo A. R. Silva wrote:
> NULL check at line 376: if (!chip) {, implies chip might be NULL.
> Function dev_get_drvdata() dereference pointer chip.
> Move pointer tmp_dev assignment after the NULL check.
chip cannot be null in st33zp24_send, please remove the bogus if
instead.
Jason
[toc] | [prev] | [next] | [standalone]
| From | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| Date | 2017-05-31 00:50 +0200 |
| Message-ID | <tMY7D-4OE-3@gated-at.bofh.it> |
| In reply to | #1653685 |
Hi Jason,
Quoting Jason Gunthorpe <jgunthorpe@obsidianresearch.com>:
> On Tue, May 30, 2017 at 05:05:20PM -0500, Gustavo A. R. Silva wrote:
>> NULL check at line 376: if (!chip) {, implies chip might be NULL.
>> Function dev_get_drvdata() dereference pointer chip.
>> Move pointer tmp_dev assignment after the NULL check.
>
> chip cannot be null in st33zp24_send, please remove the bogus if
> instead.
>
I get it.
Thanks for clarifying.
--
Gustavo A. R. Silva
[toc] | [prev] | [next] | [standalone]
| From | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| Date | 2017-05-31 02:10 +0200 |
| Subject | [PATCH] char: tpm: remove unnecessary code |
| Message-ID | <tMZn4-5K0-9@gated-at.bofh.it> |
| In reply to | #1653693 |
Remove unnecessary code. Pointer chip cannot be NULL in st33zp24_send(). Addresses-Coverity-ID: 1397648 Cc: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> --- drivers/char/tpm/st33zp24/st33zp24.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c index 4d1dc8b..ca74c24 100644 --- a/drivers/char/tpm/st33zp24/st33zp24.c +++ b/drivers/char/tpm/st33zp24/st33zp24.c @@ -373,8 +373,6 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf, int ret; u8 data; - if (!chip) - return -EBUSY; if (len < TPM_HEADER_SIZE) return -EBUSY; -- 2.5.0
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web