netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] dummy: Add ndo_uninit().
@ 2012-04-15 23:26 Hiroaki SHIMODA
  2012-04-17  3:57 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Hiroaki SHIMODA @ 2012-04-15 23:26 UTC (permalink / raw)
  To: davem; +Cc: netdev

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>
---
 drivers/net/dummy.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index d5c6d92..442d91a 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -107,14 +107,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_rx_mode	= set_multicast_list,
@@ -128,7 +128,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;
-- 
1.7.8.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] dummy: Add ndo_uninit().
  2012-04-15 23:26 [PATCH net] dummy: Add ndo_uninit() Hiroaki SHIMODA
@ 2012-04-17  3:57 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-04-17  3:57 UTC (permalink / raw)
  To: shimoda.hiroaki; +Cc: netdev

From: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>
Date: Mon, 16 Apr 2012 08:26:01 +0900

> 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>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-17  3:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-15 23:26 [PATCH net] dummy: Add ndo_uninit() Hiroaki SHIMODA
2012-04-17  3:57 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).