Skip to content

Commit

Permalink
tpm: Only call pm_runtime_get_sync if device has a parent
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stefan Berger authored and Jarkko Sakkinen committed Nov 27, 2016
1 parent 2528a64 commit 6804f6b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/char/tpm/tpm-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -400,7 +401,8 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const u8 *buf, size_t bufsiz,
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);
Expand Down

0 comments on commit 6804f6b

Please sign in to comment.