Skip to content

Commit

Permalink
dummy: Add ndo_uninit().
Browse files Browse the repository at this point in the history
[ Upstream commit 890fdf2 ]

In register_netdevice(), when ndo_init() is successful and later
some error occurred, ndo_uninit() will be called.
So dummy deivce is desirable to implement ndo_uninit() method
to free percpu stats for this case.
And, ndo_uninit() is also called along with dev->destructor() when
device is unregistered, so in order to prevent dev->dstats from
being freed twice, dev->destructor is modified to free_netdev().

Signed-off-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
hiroa-ki authored and gregkh committed Apr 27, 2012
1 parent b447077 commit 3286761
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/net/dummy.c
Expand Up @@ -106,14 +106,14 @@ static int dummy_dev_init(struct net_device *dev)
return 0;
}

static void dummy_dev_free(struct net_device *dev)
static void dummy_dev_uninit(struct net_device *dev)
{
free_percpu(dev->dstats);
free_netdev(dev);
}

static const struct net_device_ops dummy_netdev_ops = {
.ndo_init = dummy_dev_init,
.ndo_uninit = dummy_dev_uninit,
.ndo_start_xmit = dummy_xmit,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_multicast_list = set_multicast_list,
Expand All @@ -127,7 +127,7 @@ static void dummy_setup(struct net_device *dev)

/* Initialize the device structure. */
dev->netdev_ops = &dummy_netdev_ops;
dev->destructor = dummy_dev_free;
dev->destructor = free_netdev;

/* Fill in device structure with ethernet-generic values. */
dev->tx_queue_len = 0;
Expand Down

0 comments on commit 3286761

Please sign in to comment.