[PATCH] image: Avoid erroneous double byte-swap in CRC value

Tom Rini trini at konsulko.com
Wed Sep 15 00:44:42 CEST 2021


On Tue, Sep 14, 2021 at 03:53:33PM -0500, Alexandru Gagniuc wrote:

> The hash algorithm selection was streamlined in commit 92055e138f28
> ("image: Drop if/elseif hash selection in calculate_hash()"). Said
> commit kept the call to cpu_to_uimage() to convert the CRC to big
> endian format.
> 
> This would have been correct when calling crc32_wd(). However, the
> ->hash_func_ws member of crc32 points to crc32_wd_buf(), which already
> converts the CRC to big endian. On a little endian host, doing both
> conversions results in a little-endian CRC. This is incorrect.
> 
> To remedy this, simply drop the call to cpu_to_uimage(), thus only
> doing the byte-order conversion once.
> 
> Fixes: 92055e138f28 ("image: Drop if/elseif hash selection in
>        calculate_hash()")
> Tested-by: Tom Rini <trini at konsulko.com>
> Signed-off-by: Alexandru Gagniuc <mr.nuke.me at gmail.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210914/2cde76c2/attachment.sig>


More information about the U-Boot mailing list