summaryrefslogtreecommitdiff
path: root/drivers/char/tpm
diff options
context:
space:
mode:
authorStefan Berger <stefanb@linux.vnet.ibm.com>2016-11-07 15:14:33 +0300
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2016-11-28 02:31:31 +0300
commit6804f6bba09997393904a112f2043963a8e08abf (patch)
treeba8fc05633ceb4f71eaa0a719c1ef1f5840b6601 /drivers/char/tpm
parent2528a64664f8a463d85b6e6876b4025042687553 (diff)
downloadlinux-6804f6bba09997393904a112f2043963a8e08abf.tar.xz
tpm: Only call pm_runtime_get_sync if device has a parent
Only call pm_runtime_get_sync if the device has a parent. This change fixes a crash in the tpm_vtpm_proxy driver since that driver does not have a parent device. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Diffstat (limited to 'drivers/char/tpm')
-rw-r--r--drivers/char/tpm/tpm-interface.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index ef0fcdb40cc3..a2688ac2b48f 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -357,7 +357,8 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const u8 *buf, size_t bufsiz,
if (!(flags & TPM_TRANSMIT_UNLOCKED))
mutex_lock(&chip->tpm_mutex);
- pm_runtime_get_sync(chip->dev.parent);
+ if (chip->dev.parent)
+ pm_runtime_get_sync(chip->dev.parent);
rc = chip->ops->send(chip, (u8 *) buf, count);
if (rc < 0) {
@@ -400,7 +401,8 @@ out_recv:
dev_err(&chip->dev,
"tpm_transmit: tpm_recv: error %zd\n", rc);
out:
- pm_runtime_put_sync(chip->dev.parent);
+ if (chip->dev.parent)
+ pm_runtime_put_sync(chip->dev.parent);
if (!(flags & TPM_TRANSMIT_UNLOCKED))
mutex_unlock(&chip->tpm_mutex);