From: Dan Carpenter <dan.carpenter@oracle.com>
To: christophe.ricard@gmail.com
Cc: linux-integrity@vger.kernel.org, linux-i2c@vger.kernel.org
Subject: [bug report] tpm/tpm_i2c_stm_st33: Split tpm_i2c_tpm_st33 in 2 layers (core + phy)
Date: Fri, 24 Sep 2021 12:53:24 +0300 [thread overview]
Message-ID: <20210924095324.GA21453@kili> (raw)
[ Ancient code. Never use your permanent Gmail address for kernel
development if you want to have peace in your life. - dan ]
Hello Christophe Ricard,
The patch bf38b8710892: "tpm/tpm_i2c_stm_st33: Split tpm_i2c_tpm_st33
in 2 layers (core + phy)" from Mar 8, 2015, leads to the following
Smatch static checker warning:
drivers/char/tpm/st33zp24/st33zp24.c:117 check_locality()
error: uninitialized symbol 'data'.
drivers/char/tpm/st33zp24/st33zp24.c
110 static bool check_locality(struct tpm_chip *chip)
111 {
112 struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
113 u8 data;
114 u8 status;
115
116 status = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_ACCESS, &data, 1);
--> 117 if (status && (data &
The ->recv() functions, st33zp24_i2c_recv() and st33zp24_spi_recv(),
return negative error codes.
st33zp24_i2c_recv() is especially of problematic because theoretically
it could return 1 on error. The i2c_master_recv() function is tricky.
It would be better if it returned negative and zero instead of returning
the number of bytes sent.
USB had this same issue so Greg added new helper functions in commit
719b8f2850d3 ("USB: add usb_control_msg_send() and usb_control_msg_recv()")
118 (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
119 (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID))
120 return true;
121
122 return false;
123 } /* check_locality() */
regards,
dan carpenter
reply other threads:[~2021-09-24 9:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210924095324.GA21453@kili \
--to=dan.carpenter@oracle.com \
--cc=christophe.ricard@gmail.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-integrity@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