Commit 890fdf2a0cb88202d1427589db2cf29c1bdd3c1d

Authored by Hiroaki SHIMODA
Committed by David S. Miller
1 parent a99ff7d012

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>

Showing 1 changed file with 3 additions and 3 deletions Side-by-side Diff

... ... @@ -107,14 +107,14 @@
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,7 +128,7 @@
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;