From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-integrity@vger.kernel.org,
"Jarkko Sakkinen" <jarkko.sakkinen@linux.intel.com>,
"Jason Gunthorpe" <jgunthorpe@obsidianresearch.com>,
"Peter Hüwe" <PeterHuewe@gmx.de>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] tpm_tis_core: Use common error handling code in tpm_tis_send_data()
Date: Sun, 22 Oct 2017 12:16:19 +0200 [thread overview]
Message-ID: <fb0a6fbb-db2f-ce3f-f1c2-02f934accc4e@users.sourceforge.net> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 22 Oct 2017 11:41:09 +0200
Add a jump target so that a specific error code assignment for timeout
conditions will be in the implementation only at the end of this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/char/tpm/tpm_tis_core.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index fdde971bc810..3681f7a74d1b 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -262,12 +262,10 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
status = tpm_tis_status(chip);
if ((status & TPM_STS_COMMAND_READY) == 0) {
tpm_tis_ready(chip);
- if (wait_for_tpm_stat
- (chip, TPM_STS_COMMAND_READY, chip->timeout_b,
- &priv->int_queue, false) < 0) {
- rc = -ETIME;
- goto out_err;
- }
+ if (wait_for_tpm_stat(chip, TPM_STS_COMMAND_READY,
+ chip->timeout_b, &priv->int_queue, false)
+ < 0)
+ goto report_timeout;
}
while (count < len - 1) {
@@ -286,10 +284,9 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
count += burstcnt;
if (wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
- &priv->int_queue, false) < 0) {
- rc = -ETIME;
- goto out_err;
- }
+ &priv->int_queue, false) < 0)
+ goto report_timeout;
+
status = tpm_tis_status(chip);
if (!itpm && (status & TPM_STS_DATA_EXPECT) == 0) {
rc = -EIO;
@@ -303,10 +300,9 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
goto out_err;
if (wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
- &priv->int_queue, false) < 0) {
- rc = -ETIME;
- goto out_err;
- }
+ &priv->int_queue, false) < 0)
+ goto report_timeout;
+
status = tpm_tis_status(chip);
if (!itpm && (status & TPM_STS_DATA_EXPECT) != 0) {
rc = -EIO;
@@ -315,6 +311,8 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
return 0;
+report_timeout:
+ rc = -ETIME;
out_err:
tpm_tis_ready(chip);
return rc;
--
2.14.2
next reply other threads:[~2017-10-22 10:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-22 10:16 SF Markus Elfring [this message]
2017-10-23 7:34 ` [PATCH] tpm_tis_core: Use common error handling code in tpm_tis_send_data() Dan Carpenter
2017-10-23 13:42 ` Jarkko Sakkinen
2017-10-23 13:51 ` SF Markus Elfring
2017-10-24 13:55 ` Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fb0a6fbb-db2f-ce3f-f1c2-02f934accc4e@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=PeterHuewe@gmx.de \
--cc=jarkko.sakkinen@linux.intel.com \
--cc=jgunthorpe@obsidianresearch.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).