Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dummy: Add ndo_uninit().

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>

authored by

Hiroaki SHIMODA and committed by
David S. Miller
890fdf2a a99ff7d0

+3 -3
+3 -3
drivers/net/dummy.c
··· 107 107 return 0; 108 108 } 109 109 110 - static void dummy_dev_free(struct net_device *dev) 110 + static void dummy_dev_uninit(struct net_device *dev) 111 111 { 112 112 free_percpu(dev->dstats); 113 - free_netdev(dev); 114 113 } 115 114 116 115 static const struct net_device_ops dummy_netdev_ops = { 117 116 .ndo_init = dummy_dev_init, 117 + .ndo_uninit = dummy_dev_uninit, 118 118 .ndo_start_xmit = dummy_xmit, 119 119 .ndo_validate_addr = eth_validate_addr, 120 120 .ndo_set_rx_mode = set_multicast_list, ··· 128 128 129 129 /* Initialize the device structure. */ 130 130 dev->netdev_ops = &dummy_netdev_ops; 131 - dev->destructor = dummy_dev_free; 131 + dev->destructor = free_netdev; 132 132 133 133 /* Fill in device structure with ethernet-generic values. */ 134 134 dev->tx_queue_len = 0;