Commit bf3c0850 authored by Alexander Viro's avatar Alexander Viro Committed by Stephen Hemminger

[wan hostess_sv11] sane net_device allocation

Sane allocation in sv11.  Switched it to SET_MODULE_OWNER(), while we are
at it.  Fixed a leak on exit and destroy-before-unregister race.
parent 63f3ca28
......@@ -122,7 +122,6 @@ static int hostess_open(struct net_device *d)
*/
netif_start_queue(d);
MOD_INC_USE_COUNT;
return 0;
}
......@@ -154,7 +153,6 @@ static int hostess_close(struct net_device *d)
z8530_sync_txdma_close(d, &sv11->sync.chanA);
break;
}
MOD_DEC_USE_COUNT;
return 0;
}
......@@ -203,6 +201,16 @@ static int hostess_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p
return 0;
}
static void sv11_setup(struct net_device *dev)
{
dev->open = hostess_open;
dev->stop = hostess_close;
dev->hard_start_xmit = hostess_queue_xmit;
dev->get_stats = hostess_get_stats;
dev->do_ioctl = hostess_ioctl;
dev->neigh_setup = hostess_neigh_setup_dev;
}
/*
* Description block for a Comtrol Hostess SV11 card
*/
......@@ -229,10 +237,12 @@ static struct sv11_device *sv11_init(int iobase, int irq)
memset(sv, 0, sizeof(*sv));
sv->if_ptr=&sv->netdev;
sv->netdev.dev=(struct net_device *)kmalloc(sizeof(struct net_device), GFP_KERNEL);
sv->netdev.dev = alloc_netdev(0, "hdlc%d", sv11_setup);
if(!sv->netdev.dev)
goto fail2;
SET_MODULE_OWNER(sv->netdev.dev);
dev=&sv->sync;
/*
......@@ -326,16 +336,6 @@ static struct sv11_device *sv11_init(int iobase, int irq)
d->base_addr = iobase;
d->irq = irq;
d->priv = sv;
d->init = NULL;
d->open = hostess_open;
d->stop = hostess_close;
d->hard_start_xmit = hostess_queue_xmit;
d->get_stats = hostess_get_stats;
d->set_multicast_list = NULL;
d->do_ioctl = hostess_ioctl;
d->neigh_setup = hostess_neigh_setup_dev;
d->set_mac_address = NULL;
if(register_netdev(d))
{
......@@ -357,7 +357,7 @@ static struct sv11_device *sv11_init(int iobase, int irq)
fail:
free_irq(irq, dev);
fail1:
kfree(sv->netdev.dev);
free_netdev(sv->netdev.dev);
fail2:
kfree(sv);
fail3:
......@@ -368,8 +368,8 @@ static struct sv11_device *sv11_init(int iobase, int irq)
static void sv11_shutdown(struct sv11_device *dev)
{
sppp_detach(dev->netdev.dev);
z8530_shutdown(&dev->sync);
unregister_netdev(dev->netdev.dev);
z8530_shutdown(&dev->sync);
free_irq(dev->sync.irq, dev);
if(dma)
{
......@@ -378,6 +378,8 @@ static void sv11_shutdown(struct sv11_device *dev)
free_dma(dev->sync.chanA.txdma);
}
release_region(dev->sync.chanA.ctrlio-1, 8);
free_netdev(dev->netdev.dev);
kfree(dev);
}
#ifdef MODULE
......
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