Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1653628

[PATCH] char: tmp: fix potential null pointer dereference

From "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Newsgroups linux.kernel
Subject [PATCH] char: tmp: fix potential null pointer dereference
Date 2017-05-31 00:00 +0200
Message-ID <tMXlh-4i6-51@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


NULL check at line 147: if (chip) {, implies chip might be NULL.
Function dev_get_drvdata() dereference pointer chip.
Move pointer priv assignment inside the IF block that checks
pointer chip.

Addresses-Coverity-ID: 1397646
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/char/tpm/tpm_atmel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index 0d322ab..0826efd 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -142,9 +142,10 @@ static struct platform_device *pdev;
 static void atml_plat_remove(void)
 {
 	struct tpm_chip *chip = dev_get_drvdata(&pdev->dev);
-	struct tpm_atmel_priv *priv = dev_get_drvdata(&chip->dev);
+	struct tpm_atmel_priv *priv;
 
 	if (chip) {
+		priv = dev_get_drvdata(&chip->dev);
 		tpm_chip_unregister(chip);
 		if (priv->have_region)
 			atmel_release_region(priv->base, priv->region_size);
-- 
2.5.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] char: tmp: fix potential null pointer dereference "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-05-31 00:00 +0200
  Re: [PATCH] char: tmp: fix potential null pointer dereference Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2017-05-31 14:20 +0200

csiph-web