tpm: add request_locality before write TPM_INT_ENABLE
authorChen Jun <chenjun102@huawei.com>
Wed, 13 Oct 2021 06:25:56 +0000 (06:25 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 08:00:51 +0000 (09:00 +0100)
[ Upstream commit 0ef333f5ba7f24f5d8478425c163d3097f1c7afd ]

Locality is not appropriately requested before writing the int mask.
Add the missing boilerplate.

Fixes: e6aef069b6e9 ("tpm_tis: convert to using locality callbacks")
Signed-off-by: Chen Jun <chenjun102@huawei.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/char/tpm/tpm_tis_core.c

index 1ac9abcdad52ab30f0ac52b8c32fe797dc931b1f..9e42943f6a5992615fd1791e4c89e8279b7c5e94 100644 (file)
@@ -809,7 +809,15 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
        intmask |= TPM_INTF_CMD_READY_INT | TPM_INTF_LOCALITY_CHANGE_INT |
                   TPM_INTF_DATA_AVAIL_INT | TPM_INTF_STS_VALID_INT;
        intmask &= ~TPM_GLOBAL_INT_ENABLE;
+
+       rc = request_locality(chip, 0);
+       if (rc < 0) {
+               rc = -ENODEV;
+               goto out_err;
+       }
+
        tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask);
+       release_locality(chip, 0);
 
        rc = tpm2_probe(chip);
        if (rc)