[PATCH] fix moxa crash with more than one 1 board
Linux Kernel Mailing List <[email protected]> Sat, 30 Apr 2005 14:05:23 +0000
| Newsgroups | gmane.linux.kernel.commits.2-4 |
|---|---|
| Message-ID | <[email protected]> |
ChangeSet 1.1511, 2005/04/30 11:05:23-03:00, [email protected] [PATCH] fix moxa crash with more than one 1 board SYMPTOMS: The current Moxa Intellio driver (moxa.c) panics when using > 1 board. BACKGROUND: The Moxa board needs a firmware download (see http://www.moxa.com/drivers/C320T/Linux/v5.4/MXDRV.TGZ, command moxaload -y) prior to usage. Unfortunately, the current Linux kernel code fails during this download if more than one board are installed. EXPLANATION AND FIX: The MoxaDriverPoll function does: [...] for (card = 0; card < MAX_BOARDS; card++) { if ((ports = moxa_boards[card].numPorts) == 0) continue; if (readb(moxaIntPend[card]) == 0xff) { [...] Unfortunately, with multiple boards, there exists a point where MoxaDriverPoll() will be called when moxa_boards[card].numPorts != 0 but moxaIntPend[card] is still NULL. Result: kernel panic. Fix: use instead if ((ports = moxa_boards[card].numPorts) == 0 || moxaIntPend[card] == 0) continue; If someone who understands the code better than me proposes a better patch, I'd be delighted. [For the little story, the above patch was written after finding the bug in a remote location without internet access using a serial console for getting the panic trace...] moxa.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) diff -Nru a/drivers/char/moxa.c b/drivers/char/moxa.c --- a/drivers/char/moxa.c 2005-04-30 12:17:32 -07:00 +++ b/drivers/char/moxa.c 2005-04-30 12:17:32 -07:00 @@ -995,7 +995,8 @@ return; } for (card = 0; card < MAX_BOARDS; card++) { - if ((ports = MoxaPortsOfCard(card)) <= 0) + if ((ports = MoxaPortsOfCard(card)) <= 0 + || moxaIntPend[card] == 0) continue; ch = &moxaChannels[card * MAX_PORTS_PER_BOARD]; for (i = 0; i < ports; i++, ch++) {