mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnd Bergmann <arndbergmann@googlemail.com>
To: Mike Frysinger <vapier.adi@gmail.com>
Cc: Matt Fleming <matt@console-pimps.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] lib/checksum.c: lib/checksum: fix one more thinko
Date: Sun, 25 Oct 2009 11:03:22 +0100	[thread overview]
Message-ID: <200910251103.22996.arnd@arndb.de> (raw)
In-Reply-To: <8bd0f97a0910241551x7216c2b4sb8518e1a12ff346e@mail.gmail.com>

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>

---

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++;

      reply	other threads:[~2009-10-25 10:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-25 14:20 [PATCH] lib/checksum.c: Fix another endianess bug Matt Fleming
2009-09-25 17:00 ` Mike Frysinger
2009-09-28  8:07   ` Matt Fleming
2009-09-28 20:39     ` Mike Frysinger
2009-10-24 11:59       ` Matt Fleming
2009-10-24 22:51         ` Mike Frysinger
2009-10-25 10:03           ` Arnd Bergmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200910251103.22996.arnd@arndb.de \
    --to=arndbergmann@googlemail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@console-pimps.org \
    --cc=vapier.adi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome