Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1522722 > unrolled thread
| Started by | Colin King <colin.king@canonical.com> |
|---|---|
| First post | 2016-11-15 14:30 +0100 |
| Last post | 2016-11-15 18:40 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] tpm: return -ENODEV if np is not set Colin King <colin.king@canonical.com> - 2016-11-15 14:30 +0100
Re: [PATCH] tpm: return -ENODEV if np is not set Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-15 18:40 +0100
| From | Colin King <colin.king@canonical.com> |
|---|---|
| Date | 2016-11-15 14:30 +0100 |
| Subject | [PATCH] tpm: return -ENODEV if np is not set |
| Message-ID | <sDLYe-5sD-43@gated-at.bofh.it> |
From: Colin Ian King <colin.king@canonical.com> device_node np contains a garbage value from the stack and it is only set if chip->dev.parent->of_node is not null. Thus the check for a null np won't spot a garbage value of np from the stack if chip->dev.parent->of_node is null and if np contains an garbage non-null value. I believe the correct fix is to return -ENODEV if and only if chip->dev.parent->of_node is null. Found with static analysis by CoverityScan, CID 1377755 Signed-off-by: Colin Ian King <colin.king@canonical.com> --- drivers/char/tpm/tpm_of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm_of.c b/drivers/char/tpm/tpm_of.c index 3af829f..1426590 100644 --- a/drivers/char/tpm/tpm_of.c +++ b/drivers/char/tpm/tpm_of.c @@ -31,7 +31,7 @@ int read_log_of(struct tpm_chip *chip) log = &chip->log; if (chip->dev.parent->of_node) np = chip->dev.parent->of_node; - if (!np) + else return -ENODEV; sizep = of_get_property(np, "linux,sml-size", NULL); -- 2.10.2
[toc] | [next] | [standalone]
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Date | 2016-11-15 18:40 +0100 |
| Message-ID | <sDPS9-7Wd-5@gated-at.bofh.it> |
| In reply to | #1522722 |
On Tue, Nov 15, 2016 at 01:27:22PM +0000, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > device_node np contains a garbage value from the stack and it > is only set if chip->dev.parent->of_node is not null. Thus the > check for a null np won't spot a garbage value of np from the > stack if chip->dev.parent->of_node is null and if np contains > an garbage non-null value. > > I believe the correct fix is to return -ENODEV if and only if > chip->dev.parent->of_node is null. > > Found with static analysis by CoverityScan, CID 1377755 > > Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> /Jarkko > --- > drivers/char/tpm/tpm_of.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/char/tpm/tpm_of.c b/drivers/char/tpm/tpm_of.c > index 3af829f..1426590 100644 > --- a/drivers/char/tpm/tpm_of.c > +++ b/drivers/char/tpm/tpm_of.c > @@ -31,7 +31,7 @@ int read_log_of(struct tpm_chip *chip) > log = &chip->log; > if (chip->dev.parent->of_node) > np = chip->dev.parent->of_node; > - if (!np) > + else > return -ENODEV; > > sizep = of_get_property(np, "linux,sml-size", NULL); > -- > 2.10.2 >
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web