On 2020/11/29 21:56, Toshiaki Makita wrote:
On 2020/11/26 22:23, Yang Yingliang wrote:
...
Reported-by: Hulk Robot <hul...@huawei.com>
Signed-off-by: Yang Yingliang <yangyingli...@huawei.com>
---
net/core/dev.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/net/core/dev.c b/net/core/dev.c
index 82dc6b48e45f..907204395b64 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10000,6 +10000,17 @@ int register_netdevice(struct net_device *dev)
ret = notifier_to_errno(ret);
if (ret) {
rollback_registered(dev);
+ /*
+ * In common case, priv_destructor() will be
As per netdev-faq, the comment style should be
/* foobar blah blah blah
* another line of text
*/
rather than
/*
* foobar blah blah blah
* another line of text
*/
+ * called in netdev_run_todo() after calling
+ * ndo_uninit() in rollback_registered().
+ * But in this case, priv_destructor() will
+ * never be called, then it causes memory
+ * leak, so we should call priv_destructor()
+ * here.
+ */
+ if (dev->priv_destructor)
+ dev->priv_destructor(dev);
To be in line with netdev_run_todo(), I think priv_destructor() should be
called after "dev->reg_state = NETREG_UNREGISTERED".
OK, I will send a v2 later.
Toshiaki Makita
rcu_barrier();
dev->reg_state = NETREG_UNREGISTERED;