Skip to content

Commit

Permalink
tpm: check the chip reference before using it
Browse files Browse the repository at this point in the history
If a driver calls tpm_dev_vendor_release for a device already released
then the driver will oops.

Signed-off-by: Andi Shyti <andi.shyti@gmail.com>
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
  • Loading branch information
Andi Shyti authored and Rajiv Andrade committed Jun 12, 2012
1 parent dad79cb commit 3072928
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/char/tpm/tpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,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);

Expand All @@ -1347,6 +1350,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);
Expand Down

0 comments on commit 3072928

Please sign in to comment.