Skip to content

Commit

Permalink
tpm: return -ENODEV if np is not set
Browse files Browse the repository at this point in the history
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>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
  • Loading branch information
Colin Ian King authored and Jarkko Sakkinen committed Nov 27, 2016
1 parent 5efae7d commit 79eec5b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/char/tpm/tpm_of.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int tpm_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);
Expand Down

0 comments on commit 79eec5b

Please sign in to comment.