Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Stefan Berger and committed by
Jarkko Sakkinen
6804f6bb 2528a646

+4 -2
+4 -2
drivers/char/tpm/tpm-interface.c
··· 357 357 if (!(flags & TPM_TRANSMIT_UNLOCKED)) 358 358 mutex_lock(&chip->tpm_mutex); 359 359 360 - pm_runtime_get_sync(chip->dev.parent); 360 + if (chip->dev.parent) 361 + pm_runtime_get_sync(chip->dev.parent); 361 362 362 363 rc = chip->ops->send(chip, (u8 *) buf, count); 363 364 if (rc < 0) { ··· 401 400 dev_err(&chip->dev, 402 401 "tpm_transmit: tpm_recv: error %zd\n", rc); 403 402 out: 404 - pm_runtime_put_sync(chip->dev.parent); 403 + if (chip->dev.parent) 404 + pm_runtime_put_sync(chip->dev.parent); 405 405 406 406 if (!(flags & TPM_TRANSMIT_UNLOCKED)) 407 407 mutex_unlock(&chip->tpm_mutex);