2012-05-28 16:42:55

by Andi Shyti

[permalink] [raw]
Subject: [PATCH v2] tpm: check the chip reference before using it

If a driver calls tpm_dev_vendor_release for a device already released
then the driver will oops.

Signed-off-by: Andi Shyti <[email protected]>
Signed-off-by: Peter Huewe <[email protected]>
---
drivers/char/tpm/tpm.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index ad7c732..f5cabf5 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1322,6 +1322,9 @@ EXPORT_SYMBOL_GPL(tpm_pm_resume);

void tpm_dev_vendor_release(struct tpm_chip *chip)
{
+ if (!chip)
+ return;
+
if (chip->vendor.release)
chip->vendor.release(chip->dev);

@@ -1339,6 +1342,9 @@ void tpm_dev_release(struct device *dev)
{
struct tpm_chip *chip = dev_get_drvdata(dev);

+ if (!chip)
+ return;
+
tpm_dev_vendor_release(chip);

chip->release(dev);
--
1.7.10


2012-06-12 21:22:05

by Rajiv Andrade

[permalink] [raw]
Subject: Re: [PATCH v2] tpm: check the chip reference before using it

On Mon, 28 May 2012, Andi Shyti wrote:

> If a driver calls tpm_dev_vendor_release for a device already released
> then the driver will oops.
>
> Signed-off-by: Andi Shyti <[email protected]>
> Signed-off-by: Peter Huewe <[email protected]>

Thanks Andi, putting in a git pull request.

Rajiv