* [PATCH] nvmem: u-boot-env: fix crc32 casting type
@ 2022-08-18 4:38 Rafał Miłecki
2022-08-29 6:25 ` Ahmad Fatoum
0 siblings, 1 reply; 2+ messages in thread
From: Rafał Miłecki @ 2022-08-18 4:38 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: Tom Rini, Ahmad Fatoum, linux-arm-kernel, u-boot, linux-kernel,
Rafał Miłecki, kernel test robot
From: Rafał Miłecki <rafal@milecki.pl>
This fixes:
drivers/nvmem/u-boot-env.c:141:17: sparse: sparse: cast to restricted __le32
Reported-by: kernel test robot <lkp@intel.com>
Fixes: f955dc1445069 ("nvmem: add driver handling U-Boot environment variables")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
drivers/nvmem/u-boot-env.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvmem/u-boot-env.c b/drivers/nvmem/u-boot-env.c
index 9b9abfb8f187..fb993ef4249f 100644
--- a/drivers/nvmem/u-boot-env.c
+++ b/drivers/nvmem/u-boot-env.c
@@ -138,7 +138,7 @@ static int u_boot_env_parse(struct u_boot_env *priv)
data_offset = offsetof(struct u_boot_env_image_redundant, data);
break;
}
- crc32 = le32_to_cpu(*(uint32_t *)(buf + crc32_offset));
+ crc32 = le32_to_cpu(*(__le32 *)(buf + crc32_offset));
crc32_data_len = priv->mtd->size - crc32_data_offset;
data_len = priv->mtd->size - data_offset;
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] nvmem: u-boot-env: fix crc32 casting type
2022-08-18 4:38 [PATCH] nvmem: u-boot-env: fix crc32 casting type Rafał Miłecki
@ 2022-08-29 6:25 ` Ahmad Fatoum
0 siblings, 0 replies; 2+ messages in thread
From: Ahmad Fatoum @ 2022-08-29 6:25 UTC (permalink / raw)
To: Rafał Miłecki, Srinivas Kandagatla
Cc: Tom Rini, linux-arm-kernel, u-boot, linux-kernel,
Rafał Miłecki, kernel test robot
Hello Rafał,
On 18.08.22 06:38, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
>
> This fixes:
> drivers/nvmem/u-boot-env.c:141:17: sparse: sparse: cast to restricted __le32
>
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: f955dc1445069 ("nvmem: add driver handling U-Boot environment variables")
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
> drivers/nvmem/u-boot-env.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvmem/u-boot-env.c b/drivers/nvmem/u-boot-env.c
> index 9b9abfb8f187..fb993ef4249f 100644
> --- a/drivers/nvmem/u-boot-env.c
> +++ b/drivers/nvmem/u-boot-env.c
> @@ -138,7 +138,7 @@ static int u_boot_env_parse(struct u_boot_env *priv)
> data_offset = offsetof(struct u_boot_env_image_redundant, data);
> break;
> }
> - crc32 = le32_to_cpu(*(uint32_t *)(buf + crc32_offset));
> + crc32 = le32_to_cpu(*(__le32 *)(buf + crc32_offset));
I had to do a double take to make sure alignment is not violated.
It's not, because crc32_offset is always zero.
How about rewriting this as
/* CRC32 is always at offset 0 */
crc32 = le32_to_cpup(buf);
To make the alignment clear to the reader?
> crc32_data_len = priv->mtd->size - crc32_data_offset;
> data_len = priv->mtd->size - data_offset;
>
Cheers,
Ahmad
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-29 6:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18 4:38 [PATCH] nvmem: u-boot-env: fix crc32 casting type Rafał Miłecki
2022-08-29 6:25 ` Ahmad Fatoum
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).