Commit 428bc597 authored by Arnd Bergmann's avatar Arnd Bergmann

lib/checksum: fix one more thinko

When do_csum gets unaligned data, we really need to treat
the first byte as an even byte, not an odd byte, because
we swap the two halves later.

Found by Mike's checksum-selftest module.
Reported-by: default avatarMike Frysinger <vapier.adi@gmail.com>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 217a8c7b
...@@ -57,9 +57,9 @@ static unsigned int do_csum(const unsigned char *buff, int len) ...@@ -57,9 +57,9 @@ static unsigned int do_csum(const unsigned char *buff, int len)
odd = 1 & (unsigned long) buff; odd = 1 & (unsigned long) buff;
if (odd) { if (odd) {
#ifdef __LITTLE_ENDIAN #ifdef __LITTLE_ENDIAN
result = *buff;
#else
result += (*buff << 8); result += (*buff << 8);
#else
result = *buff;
#endif #endif
len--; len--;
buff++; buff++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment