Skip to content

Commit

Permalink
lib/checksum: fix one more thinko
Browse files Browse the repository at this point in the history
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: Mike Frysinger <[email protected]>
Signed-off-by: Arnd Bergmann <[email protected]>
  • Loading branch information
arndb committed Nov 3, 2009
1 parent 20c1f64 commit 0a5549e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/checksum.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ static unsigned int do_csum(const unsigned char *buff, int len)
odd = 1 & (unsigned long) buff;
if (odd) {
#ifdef __LITTLE_ENDIAN
result = *buff;
#else
result += (*buff << 8);
#else
result = *buff;
#endif
len--;
buff++;
Expand Down

0 comments on commit 0a5549e

Please sign in to comment.