Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01cfaf0d authored by Dirk Eibach's avatar Dirk Eibach Committed by Linus Torvalds
Browse files

[PATCH] char/moxa.c: fix endianess and multiple-card issues



While testing Moxa C218T/PCI on PowerPC 405EP I found that loading firmware
using the linux kernel driver fails because calculation of the checksum is
not endianess independent in the original code.

After I fixed this I found that uploading firmware in a system with
multiple cards causes a kernel oops.  I had a look in the recent moxa
sources and found that they do some kind of locking there.  Applying this
lock fixed the problem.

Alan sayeth:

  Checksum changes are clearly correct.  Other changes is an improvement but
  not I think enough to handle malicious firmware attacks.  That said such an
  attacker has CAP_SYS_RAWIO anyway so that part is irrelevant except for
  neatness.

[akpm@osdl.org: cleanups]
Signed-off-by: default avatarDirk Eibach <eibach@gdsys.de>
Acked-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a0cc621f
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ typedef struct _moxa_board_conf {

static moxa_board_conf moxa_boards[MAX_BOARDS];
static void __iomem *moxaBaseAddr[MAX_BOARDS];
static int loadstat[MAX_BOARDS];

struct moxa_str {
	int type;
@@ -1688,6 +1689,8 @@ int MoxaDriverPoll(void)
	if (moxaCard == 0)
		return (-1);
	for (card = 0; card < MAX_BOARDS; card++) {
	        if (loadstat[card] == 0)
			continue;
		if ((ports = moxa_boards[card].numPorts) == 0)
			continue;
		if (readb(moxaIntPend[card]) == 0xff) {
@@ -2903,6 +2906,7 @@ static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
		}
		break;
	}
	loadstat[cardno] = 1;
	return (0);
}

@@ -2920,7 +2924,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)
	len1 = len >> 1;
	ptr = (ushort *) moxaBuff;
	for (i = 0; i < len1; i++)
		usum += *(ptr + i);
		usum += le16_to_cpu(*(ptr + i));
	retry = 0;
	do {
		len1 = len >> 1;
@@ -2992,7 +2996,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor
	wlen = len >> 1;
	uptr = (ushort *) moxaBuff;
	for (i = 0; i < wlen; i++)
		usum += uptr[i];
		usum += le16_to_cpu(uptr[i]);
	retry = 0;
	j = 0;
	do {