2
0

802-nvmem-u-boot-env-align-endianness-of-crc32-values.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. From 0e71cac033bb7689c4dfa2e6814191337ef770f5 Mon Sep 17 00:00:00 2001
  2. From: INAGAKI Hiroshi <[email protected]>
  3. Date: Thu, 13 Oct 2022 00:51:33 +0900
  4. Subject: [PATCH] nvmem: u-boot-env: align endianness of crc32 values
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. This patch fixes crc32 error on Big-Endianness system by conversion of
  9. calculated crc32 value.
  10. Little-Endianness system:
  11. obtained crc32: Little
  12. calculated crc32: Little
  13. Big-Endianness system:
  14. obtained crc32: Little
  15. calculated crc32: Big
  16. log (APRESIA ApresiaLightGS120GT-SS, RTL8382M, Big-Endianness):
  17. [ 8.570000] u_boot_env 18001200.spi:flash@0:partitions:partition@c0000: Invalid calculated CRC32: 0x88cd6f09 (expected: 0x096fcd88)
  18. [ 8.580000] u_boot_env: probe of 18001200.spi:flash@0:partitions:partition@c0000 failed with error -22
  19. Fixes: f955dc1445069 ("nvmem: add driver handling U-Boot environment variables")
  20. Signed-off-by: INAGAKI Hiroshi <[email protected]>
  21. Acked-by: Rafał Miłecki <[email protected]>
  22. Tested-by: Christian Lamparter <[email protected]>
  23. Signed-off-by: Srinivas Kandagatla <[email protected]>
  24. ---
  25. drivers/nvmem/u-boot-env.c | 2 +-
  26. 1 file changed, 1 insertion(+), 1 deletion(-)
  27. --- a/drivers/nvmem/u-boot-env.c
  28. +++ b/drivers/nvmem/u-boot-env.c
  29. @@ -181,7 +181,7 @@ static int u_boot_env_parse(struct u_boo
  30. crc32_data_len = dev_size - crc32_data_offset;
  31. data_len = dev_size - data_offset;
  32. - calc = crc32(~0, buf + crc32_data_offset, crc32_data_len) ^ ~0L;
  33. + calc = le32_to_cpu((__le32)crc32(~0, buf + crc32_data_offset, crc32_data_len) ^ ~0L);
  34. if (calc != crc32) {
  35. dev_err(dev, "Invalid calculated CRC32: 0x%08x (expected: 0x%08x)\n", calc, crc32);
  36. err = -EINVAL;