[Patch] 2.0.pre36 Llance.c

Hans-Joachim Baader (hans@grumbeer.inka.de)
Fri, 21 Aug 1998 00:00:24 +0200 (MET DST)


Hi,

I'm currently building a new test box (another one ;-). It has an
old Novell/Eagle network card with the LANCE chip. While loading and
unloading the lance.o module I noticed two bugs:
1. The IRQ was freed twice when unloading
2. The DMA was not freed when unloading, using up DMA channels and
causing an Oops when catting /proc/dma while the module was not loaded

The following patch works for me, both as a module and built-in.
Please review, since I don't have any kernel knowledge ;-)

>From my short glance at 2.1.117 I guess the fix must be applied there
too...

--- lance.c.orig Thu Aug 20 19:16:29 1998
+++ lance.c Thu Aug 20 23:45:30 1998
@@ -288,8 +288,10 @@

enum {OLD_LANCE = 0, PCNET_ISA=1, PCNET_ISAP=2, PCNET_PCI=3, PCNET_VLB=4, PCNET_PCI_II=5, LANCE_UNKNOWN=6};

+#if defined(CONFIG_PCI)
/* Non-zero only if the current card is a PCI with BIOS-set IRQ. */
static unsigned char pci_irq_line = 0;
+#endif

/* Non-zero if lance_probe1() needs to allocate low-memory bounce buffers.
Assume yes until we know the memory size. */
@@ -360,7 +362,6 @@
if (dev->priv != NULL) {
kfree(dev->priv);
dev->priv = NULL;
- free_irq(dev->irq, NULL);
release_region(dev->base_addr, LANCE_TOTAL_SIZE);
unregister_netdev(dev);
}
@@ -1209,8 +1210,10 @@
memory if we don't. */
outw(0x0004, ioaddr+LANCE_DATA);

- if (dev->dma != 4)
+ if (dev->dma != 4) {
disable_dma(dev->dma);
+ free_dma(dev->dma);
+ }

free_irq(dev->irq, dev);

@@ -1224,6 +1227,7 @@
dev_kfree_skb(skb, FREE_WRITE);
}
}
+
for (i = 0; i < TX_RING_SIZE; i++) {
if (lp->tx_skbuff[i])
dev_kfree_skb(lp->tx_skbuff[i], FREE_WRITE);

Regards,
hjb

-- 
"Every use of Linux is a proper use of Linux."
				-- John "Maddog" Hall, Keynote at the Linux
				   Kongress in Cologne

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html