From: Toshiaki Makita <toshiaki.makita1@gmail.com>
To: Yang Yingliang <yangyingliang@huawei.com>
Cc: davem@davemloft.net, kuba@kernel.org, rkovhaev@gmail.com,
Netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH net] net: fix memory leak in register_netdevice() on error path
Date: Sun, 29 Nov 2020 22:56:38 +0900 [thread overview]
Message-ID: <3548dfef-da8f-0247-0af5-e612b540e397@gmail.com> (raw)
In-Reply-To: <20201126132312.3593725-1-yangyingliang@huawei.com>
On 2020/11/26 22:23, Yang Yingliang wrote:
...
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@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".
Toshiaki Makita
> rcu_barrier();
>
> dev->reg_state = NETREG_UNREGISTERED;
>
next prev parent reply other threads:[~2020-11-29 13:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-26 13:23 [PATCH net] net: fix memory leak in register_netdevice() on error path Yang Yingliang
2020-11-29 13:56 ` Toshiaki Makita [this message]
2020-11-30 11:13 ` Yang Yingliang
2020-11-30 4:39 ` Stephen Hemminger
2020-11-30 11:12 ` Yang Yingliang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3548dfef-da8f-0247-0af5-e612b540e397@gmail.com \
--to=toshiaki.makita1@gmail.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rkovhaev@gmail.com \
--cc=yangyingliang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).