提交 7f4a7b1b 编写于 作者: T Tomas Winkler 提交者: Greg Kroah-Hartman

tpm: tpm_try_transmit() refactor error flow.

commit 01f54664a4db0d612de0ece8e0022f21f9374e9b upstream.

First, rename out_no_locality to out_locality for bailing out on
both tpm_cmd_ready() and tpm_request_locality() failure.
Second, ignore the return value of go_to_idle() as  it may override
the return value of the actual tpm operation, the go_to_idle() error
will be caught on any consequent command.
Last, fix the wrong 'goto out', that jumped back instead of forward.

Cc: stable@vger.kernel.org
Fixes: 627448e8 ("tpm: separate cmd_ready/go_idle from runtime_pm")
Signed-off-by: NTomas Winkler <tomas.winkler@intel.com>
Reviewed-by: NJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: NJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: NJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 920735c6
...@@ -477,13 +477,15 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, ...@@ -477,13 +477,15 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip,
if (need_locality) { if (need_locality) {
rc = tpm_request_locality(chip, flags); rc = tpm_request_locality(chip, flags);
if (rc < 0) if (rc < 0) {
goto out_no_locality; need_locality = false;
goto out_locality;
}
} }
rc = tpm_cmd_ready(chip, flags); rc = tpm_cmd_ready(chip, flags);
if (rc) if (rc)
goto out; goto out_locality;
rc = tpm2_prepare_space(chip, space, ordinal, buf); rc = tpm2_prepare_space(chip, space, ordinal, buf);
if (rc) if (rc)
...@@ -547,14 +549,13 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, ...@@ -547,14 +549,13 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip,
dev_err(&chip->dev, "tpm2_commit_space: error %d\n", rc); dev_err(&chip->dev, "tpm2_commit_space: error %d\n", rc);
out: out:
rc = tpm_go_idle(chip, flags); /* may fail but do not override previous error value in rc */
if (rc) tpm_go_idle(chip, flags);
goto out;
out_locality:
if (need_locality) if (need_locality)
tpm_relinquish_locality(chip, flags); tpm_relinquish_locality(chip, flags);
out_no_locality:
if (chip->ops->clk_enable != NULL) if (chip->ops->clk_enable != NULL)
chip->ops->clk_enable(chip, false); chip->ops->clk_enable(chip, false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册