]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
lib/checksum: fix one more thinko
authorArnd Bergmann <arnd@arndb.de>
Tue, 23 Jun 2009 20:52:51 +0000 (22:52 +0200)
committerArnd Bergmann <arnd@arndb.de>
Tue, 3 Nov 2009 15:06:53 +0000 (16:06 +0100)
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 <vapier.adi@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
lib/checksum.c

index b08c2d059024d01fa7ac3b1408d4ed8f22649cf0..097508732f34fdbb9de955509685f43df2feba32 100644 (file)
@@ -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++;