bug in moxa.c driver (+ patch, please apply)

From: David Monniaux
Date: Sat Jul 03 2004 - 17:21:20 EST


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...]

David Monniaux http://www.di.ens.fr/~monniaux
Laboratoire d'informatique de l'École Normale Supérieure,
Paris, France

-
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/