* [PATCH 3/3] tpm: fix type of a local variables in tpm_tis_spi.c
@ 2017-09-13 17:26 Jarkko Sakkinen
2017-09-13 18:52 ` Jarkko Sakkinen
0 siblings, 1 reply; 2+ messages in thread
From: Jarkko Sakkinen @ 2017-09-13 17:26 UTC (permalink / raw)
To: linux-security-module
Use __le32 type for data in that format.
Fixes: 0edbfea537d1 ("tpm/tpm_tis_spi: Add support for spi phy")
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
drivers/char/tpm/tpm_tis_spi.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/drivers/char/tpm/tpm_tis_spi.c b/drivers/char/tpm/tpm_tis_spi.c
index 7e97eb07b200..bfe972959183 100644
--- a/drivers/char/tpm/tpm_tis_spi.c
+++ b/drivers/char/tpm/tpm_tis_spi.c
@@ -153,29 +153,40 @@ static int tpm_tis_spi_write_bytes(struct tpm_tis_data *data, u32 addr,
static int tpm_tis_spi_read16(struct tpm_tis_data *data, u32 addr, u16 *result)
{
+ __le16 result_le;
int rc;
- rc = data->phy_ops->read_bytes(data, addr, sizeof(u16), (u8 *)result);
+ rc = data->phy_ops->read_bytes(data, addr, sizeof(u16),
+ (u8 *)&result_le);
if (!rc)
- *result = le16_to_cpu(*result);
+ *result = le16_to_cpu(result_le);
+
return rc;
}
static int tpm_tis_spi_read32(struct tpm_tis_data *data, u32 addr, u32 *result)
{
+ __le32 result_le;
int rc;
- rc = data->phy_ops->read_bytes(data, addr, sizeof(u32), (u8 *)result);
+ rc = data->phy_ops->read_bytes(data, addr, sizeof(u32),
+ (u8 *)&result_le);
if (!rc)
- *result = le32_to_cpu(*result);
+ *result = le32_to_cpu(result_le);
+
return rc;
}
static int tpm_tis_spi_write32(struct tpm_tis_data *data, u32 addr, u32 value)
{
- value = cpu_to_le32(value);
- return data->phy_ops->write_bytes(data, addr, sizeof(u32),
- (u8 *)&value);
+ __le32 value_le;
+ int rc;
+
+ value_le = cpu_to_le32(value);
+ rc = data->phy_ops->write_bytes(data, addr, sizeof(u32),
+ (u8 *)&value_le);
+
+ return rc;
}
static const struct tpm_tis_phy_ops tpm_spi_phy_ops = {
--
2.14.1
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 3/3] tpm: fix type of a local variables in tpm_tis_spi.c
2017-09-13 17:26 [PATCH 3/3] tpm: fix type of a local variables in tpm_tis_spi.c Jarkko Sakkinen
@ 2017-09-13 18:52 ` Jarkko Sakkinen
0 siblings, 0 replies; 2+ messages in thread
From: Jarkko Sakkinen @ 2017-09-13 18:52 UTC (permalink / raw)
To: linux-security-module
Applied (as other similar) already to master because these are
very obvious things to fix. I'll wait for reviews and tests before
applying to next.
/Jarkko
On Wed, Sep 13, 2017 at 10:26:54AM -0700, Jarkko Sakkinen wrote:
> Use __le32 type for data in that format.
>
> Fixes: 0edbfea537d1 ("tpm/tpm_tis_spi: Add support for spi phy")
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---
> drivers/char/tpm/tpm_tis_spi.c | 25 ++++++++++++++++++-------
> 1 file changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_tis_spi.c b/drivers/char/tpm/tpm_tis_spi.c
> index 7e97eb07b200..bfe972959183 100644
> --- a/drivers/char/tpm/tpm_tis_spi.c
> +++ b/drivers/char/tpm/tpm_tis_spi.c
> @@ -153,29 +153,40 @@ static int tpm_tis_spi_write_bytes(struct tpm_tis_data *data, u32 addr,
>
> static int tpm_tis_spi_read16(struct tpm_tis_data *data, u32 addr, u16 *result)
> {
> + __le16 result_le;
> int rc;
>
> - rc = data->phy_ops->read_bytes(data, addr, sizeof(u16), (u8 *)result);
> + rc = data->phy_ops->read_bytes(data, addr, sizeof(u16),
> + (u8 *)&result_le);
> if (!rc)
> - *result = le16_to_cpu(*result);
> + *result = le16_to_cpu(result_le);
> +
> return rc;
> }
>
> static int tpm_tis_spi_read32(struct tpm_tis_data *data, u32 addr, u32 *result)
> {
> + __le32 result_le;
> int rc;
>
> - rc = data->phy_ops->read_bytes(data, addr, sizeof(u32), (u8 *)result);
> + rc = data->phy_ops->read_bytes(data, addr, sizeof(u32),
> + (u8 *)&result_le);
> if (!rc)
> - *result = le32_to_cpu(*result);
> + *result = le32_to_cpu(result_le);
> +
> return rc;
> }
>
> static int tpm_tis_spi_write32(struct tpm_tis_data *data, u32 addr, u32 value)
> {
> - value = cpu_to_le32(value);
> - return data->phy_ops->write_bytes(data, addr, sizeof(u32),
> - (u8 *)&value);
> + __le32 value_le;
> + int rc;
> +
> + value_le = cpu_to_le32(value);
> + rc = data->phy_ops->write_bytes(data, addr, sizeof(u32),
> + (u8 *)&value_le);
> +
> + return rc;
> }
>
> static const struct tpm_tis_phy_ops tpm_spi_phy_ops = {
> --
> 2.14.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-13 18:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-13 17:26 [PATCH 3/3] tpm: fix type of a local variables in tpm_tis_spi.c Jarkko Sakkinen
2017-09-13 18:52 ` Jarkko Sakkinen
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).