* [PATCH] tpm: return -ENODEV if np is not set
@ 2016-11-15 13:27 Colin King
[not found] ` <20161115132722.6963-1-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2016-11-15 13:27 UTC (permalink / raw)
To: Peter Huewe, Marcel Selhorst, Jarkko Sakkinen, Jason Gunthorpe,
tpmdd-devel
Cc: linux-kernel
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-15 17:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-15 13:27 [PATCH] tpm: return -ENODEV if np is not set Colin King
[not found] ` <20161115132722.6963-1-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2016-11-15 17:33 ` 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).