[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181108215104.226618623@linuxfoundation.org>
Date: Thu, 8 Nov 2018 13:50:51 -0800
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org,
Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>,
Jason Gunthorpe <jgunthorpe@...idianresearch.com>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH 4.4 036/114] tpm: fix: return rc when devm_add_action() fails
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 4f3b193dee4423d8c89c9a3e8e05f9197ea459a4 ]
Call put_device() and return error code if devm_add_action() fails.
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
Reported-by: Jason Gunthorpe <jgunthorpe@...idianresearch.com>
Fixes: 8e0ee3c9faed ("tpm: fix the cleanup of struct tpm_chip")
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
drivers/char/tpm/tpm-chip.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index e759100e41a7..28894878dcd5 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -230,7 +230,11 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
chip->cdev.owner = dev->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.17.1
Powered by blists - more mailing lists