diff options
author | Dirk Eibach <eibach@gdsys.de> | 2006-08-27 04:23:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-08-27 14:01:29 -0400 |
commit | 01cfaf0d12ae5fa092cc916ca4066ee1598e857d (patch) | |
tree | f4db2c5759345e4b06310b633b8cee241842bdf6 /drivers | |
parent | a0cc621f52a4dea10c34eeed6eb4e36b26db63dc (diff) |
[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: Dirk Eibach <eibach@gdsys.de>
Acked-by: Alan Cox <alan@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/moxa.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index 4ea7bd5f4f56..a369dd6877d8 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -142,6 +142,7 @@ typedef struct _moxa_board_conf { | |||
142 | 142 | ||
143 | static moxa_board_conf moxa_boards[MAX_BOARDS]; | 143 | static moxa_board_conf moxa_boards[MAX_BOARDS]; |
144 | static void __iomem *moxaBaseAddr[MAX_BOARDS]; | 144 | static void __iomem *moxaBaseAddr[MAX_BOARDS]; |
145 | static int loadstat[MAX_BOARDS]; | ||
145 | 146 | ||
146 | struct moxa_str { | 147 | struct moxa_str { |
147 | int type; | 148 | int type; |
@@ -1688,6 +1689,8 @@ int MoxaDriverPoll(void) | |||
1688 | if (moxaCard == 0) | 1689 | if (moxaCard == 0) |
1689 | return (-1); | 1690 | return (-1); |
1690 | for (card = 0; card < MAX_BOARDS; card++) { | 1691 | for (card = 0; card < MAX_BOARDS; card++) { |
1692 | if (loadstat[card] == 0) | ||
1693 | continue; | ||
1691 | if ((ports = moxa_boards[card].numPorts) == 0) | 1694 | if ((ports = moxa_boards[card].numPorts) == 0) |
1692 | continue; | 1695 | continue; |
1693 | if (readb(moxaIntPend[card]) == 0xff) { | 1696 | if (readb(moxaIntPend[card]) == 0xff) { |
@@ -2903,6 +2906,7 @@ static int moxaloadcode(int cardno, unsigned char __user *tmp, int len) | |||
2903 | } | 2906 | } |
2904 | break; | 2907 | break; |
2905 | } | 2908 | } |
2909 | loadstat[cardno] = 1; | ||
2906 | return (0); | 2910 | return (0); |
2907 | } | 2911 | } |
2908 | 2912 | ||
@@ -2920,7 +2924,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len) | |||
2920 | len1 = len >> 1; | 2924 | len1 = len >> 1; |
2921 | ptr = (ushort *) moxaBuff; | 2925 | ptr = (ushort *) moxaBuff; |
2922 | for (i = 0; i < len1; i++) | 2926 | for (i = 0; i < len1; i++) |
2923 | usum += *(ptr + i); | 2927 | usum += le16_to_cpu(*(ptr + i)); |
2924 | retry = 0; | 2928 | retry = 0; |
2925 | do { | 2929 | do { |
2926 | len1 = len >> 1; | 2930 | len1 = len >> 1; |
@@ -2992,7 +2996,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor | |||
2992 | wlen = len >> 1; | 2996 | wlen = len >> 1; |
2993 | uptr = (ushort *) moxaBuff; | 2997 | uptr = (ushort *) moxaBuff; |
2994 | for (i = 0; i < wlen; i++) | 2998 | for (i = 0; i < wlen; i++) |
2995 | usum += uptr[i]; | 2999 | usum += le16_to_cpu(uptr[i]); |
2996 | retry = 0; | 3000 | retry = 0; |
2997 | j = 0; | 3001 | j = 0; |
2998 | do { | 3002 | do { |