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


Groups > linux.kernel > #1334095 > unrolled thread

[PATCH 2/3] tpm: fix: return rc when devm_add_action() fails

Started byJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
First post2016-02-15 02:50 +0100
Last post2016-02-15 02:50 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/3] tpm: fix: return rc when devm_add_action() fails Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-02-15 02:50 +0100

#1334095 — [PATCH 2/3] tpm: fix: return rc when devm_add_action() fails

FromJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Date2016-02-15 02:50 +0100
Subject[PATCH 2/3] tpm: fix: return rc when devm_add_action() fails
Message-ID<r2gsx-2w1-1@gated-at.bofh.it>
Call put_device() and return error code if devm_add_action() fails.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reported-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Fixes: 8e0ee3c9faed ("tpm: fix the cleanup of struct tpm_chip")
---
 drivers/char/tpm/tpm-chip.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index 2521425..274dd01 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -88,6 +88,7 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
 				 const struct tpm_class_ops *ops)
 {
 	struct tpm_chip *chip;
+	int rc;
 
 	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
 	if (chip == NULL)
@@ -136,7 +137,11 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
 	chip->cdev.owner = chip->pdev->driver->owner;
 	chip->cdev.kobj.parent = &chip->dev.kobj;
 
-	devm_add_action(dev, (void (*)(void *)) put_device, &chip->dev);
+	rc = devm_add_action(dev, (void (*)(void *)) put_device, &chip->dev);
+	if (rc) {
+		put_device(&chip->dev);
+		return ERR_PTR(rc);
+	}
 
 	return chip;
 }
-- 
2.7.0

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web