[PATCH] lib/checksum.c: lib/checksum: fix one more thinko

From: Arnd Bergmann
Date: Sun Oct 25 2009 - 06:03:45 EST


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@xxxxxxxxx>
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>

---

On Sunday 25 October 2009, Mike Frysinger wrote:

> > Andrew, Arnd, could one of you pick this up?
>
> we've been using the generic checksum code with this fix on Blackfin
> boards for the last month and havent noticed any regressions so far

Mike,

sorry for my unresponsiveness on this one. I kept procrastinating
because I knew I need some to look at the whole logic again to make sure
I really get it right this time.

Andrew,

can you pick this one up to make sure we don't lose it again?
I could also put it into the asm-generic tree, but it feels out
of place there.

Arnd <><


diff --git a/lib/checksum.c b/lib/checksum.c
index b2e2fd4..45c9c93 100644
--- a/lib/checksum.c
+++ b/lib/checksum.c
@@ -56,9 +56,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++;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/