Commit 3072928ff2457642af0da745b88f0420b4596c48

Authored by Andi Shyti
Committed by Rajiv Andrade
1 parent dad79cb892

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 <andi.shyti@gmail.com>
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>

Showing 1 changed file with 6 additions and 0 deletions Side-by-side Diff

drivers/char/tpm/tpm.c
... ... @@ -1330,6 +1330,9 @@
1330 1330  
1331 1331 void tpm_dev_vendor_release(struct tpm_chip *chip)
1332 1332 {
  1333 + if (!chip)
  1334 + return;
  1335 +
1333 1336 if (chip->vendor.release)
1334 1337 chip->vendor.release(chip->dev);
1335 1338  
... ... @@ -1346,6 +1349,9 @@
1346 1349 void tpm_dev_release(struct device *dev)
1347 1350 {
1348 1351 struct tpm_chip *chip = dev_get_drvdata(dev);
  1352 +
  1353 + if (!chip)
  1354 + return;
1349 1355  
1350 1356 tpm_dev_vendor_release(chip);
1351 1357