]> git.baikalelectronics.ru Git - uboot.git/commit
image: Avoid erroneous double byte-swap in CRC value
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>
Tue, 14 Sep 2021 20:53:33 +0000 (15:53 -0500)
committerTom Rini <trini@konsulko.com>
Tue, 14 Sep 2021 22:44:02 +0000 (18:44 -0400)
commitac6df3f56e00365e578521fef92719f734607291
tree54006b6a9d63171e0fc61a1d243f7cc597f75c21
parentdf550d0a951a3dd2a46481bed5c5a814a0f1411c
image: Avoid erroneous double byte-swap in CRC value

The hash algorithm selection was streamlined in commit 1affd3abbe04
("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: 1affd3abbe04 ("image: Drop if/elseif hash selection in
       calculate_hash()")
Tested-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
common/image-fit.c