tpm: check the chip reference before using it
authorAndi Shyti <andi.shyti@gmail.com>
Mon, 28 May 2012 16:42:45 +0000 (18:42 +0200)
committerRajiv Andrade <srajiv@linux.vnet.ibm.com>
Tue, 12 Jun 2012 21:53:51 +0000 (18:53 -0300)
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>
drivers/char/tpm/tpm.c

index dae254d53723340d1dae7ae2b471a21b6ebfe7ff..d39b1f60ba2389c582225a1ed11f15ffa6103e53 100644 (file)
@@ -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);
 
@@ -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);