Skip to contentSkip to conversation

tpm: fix node pointer lookup

PATCH In review Arnd Bergmann 2 participants 2 messages Nov 15, 2016 TPM device driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: fix node pointer lookup

A rework left the node pointer uninitialized when the device tree is not in use:

drivers/char/tpm/tpm_of.c: In function 'read_log_of':
drivers/char/tpm/tpm_of.c:37:8: error: 'np' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This reverts the behavior to what it should be.

Fixes 4a45d9669ac1 ("tpm: replace of_find_node_by_name() with dev of_node property")
---
 drivers/char/tpm/tpm_of.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/tpm/tpm_of.c +1 -2
index 3af829f3ad59..24fa6afc2e55 100644
@@ -29,8 +29,7 @@ int read_log_of(struct tpm_chip *chip)
 	struct tpm_bios_log *log;
 
 	log = &chip->log;
-	if (chip->dev.parent->of_node)
-		np = chip->dev.parent->of_node;
+	np = chip->dev.parent->of_node;
 	if (!np)
 		return -ENODEV;
 
Signature · 4 lines
2.9.0


------------------------------------------------------------------------------
#1 lore raw
Quoted 10 lines · Arnd Bergmann

A rework left the node pointer uninitialized when the device tree is not in use:

drivers/char/tpm/tpm_of.c: In function 'read_log_of':
drivers/char/tpm/tpm_of.c:37:8: error: 'np' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This reverts the behavior to what it should be.

Fixes 4a45d9669ac1 ("tpm: replace of_find_node_by_name() with dev of_node property")

Arnd, I got patch from Colin a moment earlier so I applied that. Thank you in any case!

/Jarkko

Quoted 21 lines
---
 drivers/char/tpm/tpm_of.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/tpm/tpm_of.c +1 -2
index 3af829f3ad59..24fa6afc2e55 100644
@@ -29,8 +29,7 @@ int read_log_of(struct tpm_chip *chip)
 	struct tpm_bios_log *log;
 
 	log = &chip->log;
-	if (chip->dev.parent->of_node)
-		np = chip->dev.parent->of_node;
+	np = chip->dev.parent->of_node;
 	if (!np)
 		return -ENODEV;
 
Signature · 1 line
2.9.0