Commit 1db75d47 authored by Jochen Friedrich's avatar Jochen Friedrich Committed by Jeff Garzik

[tokenring madgemc] fix mem leaks, add proper refcounting

parent 79a79c6c
......@@ -180,8 +180,11 @@ int __init madgemc_probe(void)
if ((dev = init_trdev(NULL, 0))==NULL) {
printk("madgemc: unable to allocate dev space\n");
if (madgemc_card_list)
return 0;
return -1;
}
SET_MODULE_OWNER(dev);
dev->dma = 0;
/*
......@@ -193,6 +196,9 @@ int __init madgemc_probe(void)
card = kmalloc(sizeof(struct madgemc_card), GFP_KERNEL);
if (card==NULL) {
printk("madgemc: unable to allocate card struct\n");
kfree(dev); /* release_trdev? */
if (madgemc_card_list)
return 0;
return -1;
}
card->dev = dev;
......@@ -223,14 +229,14 @@ int __init madgemc_probe(void)
if (dev->irq == 0) {
printk("%s: invalid IRQ\n", dev->name);
goto getout;
goto getout1;
}
if (!request_region(dev->base_addr, MADGEMC_IO_EXTENT,
"madgemc")) {
printk(KERN_INFO "madgemc: unable to setup Smart MC in slot %d because of I/O base conflict at 0x%04lx\n", slot, dev->base_addr);
dev->base_addr += MADGEMC_SIF_OFFSET;
goto getout;
goto getout1;
}
dev->base_addr += MADGEMC_SIF_OFFSET;
......@@ -348,6 +354,14 @@ int __init madgemc_probe(void)
if (tmsdev_init(dev, ISA_MAX_ADDRESS, NULL)) {
printk("%s: unable to get memory for dev->priv.\n",
dev->name);
release_region(dev->base_addr-MADGEMC_SIF_OFFSET,
MADGEMC_IO_EXTENT);
kfree(card);
tmsdev_term(dev);
kfree(dev);
if (madgemc_card_list)
return 0;
return -1;
}
tp = (struct net_local *)dev->priv;
......@@ -376,10 +390,14 @@ int __init madgemc_probe(void)
madgemc_card_list = card;
} else {
printk("madgemc: register_trdev() returned non-zero.\n");
release_region(dev->base_addr-MADGEMC_SIF_OFFSET,
MADGEMC_IO_EXTENT);
kfree(card);
tmsdev_term(dev);
kfree(dev);
if (madgemc_card_list)
return 0;
return -1;
}
......@@ -389,6 +407,7 @@ int __init madgemc_probe(void)
getout:
release_region(dev->base_addr-MADGEMC_SIF_OFFSET,
MADGEMC_IO_EXTENT);
getout1:
kfree(card);
kfree(dev); /* release_trdev? */
slot++;
......@@ -696,7 +715,6 @@ static int madgemc_open(struct net_device *dev)
*/
madgemc_chipset_init(dev);
tms380tr_open(dev);
MOD_INC_USE_COUNT;
return 0;
}
......@@ -704,7 +722,6 @@ static int madgemc_close(struct net_device *dev)
{
tms380tr_close(dev);
madgemc_chipset_close(dev);
MOD_DEC_USE_COUNT;
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment