From: jouni.hogander@unikie.com (Jouni Högander)
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: netdev@vger.kernel.org, David Miller <davem@davemloft.net>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>
Subject: Re: [PATCH] net-sysfs: Fix reference count leak
Date: Mon, 18 Nov 2019 11:25:05 +0200 [thread overview]
Message-ID: <87tv718rke.fsf@unikie.com> (raw)
In-Reply-To: <20191115152416.GA377478@kroah.com> (Greg Kroah-Hartman's message of "Fri, 15 Nov 2019 23:24:16 +0800")
Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
> On Fri, Nov 15, 2019 at 02:24:12PM +0200, jouni.hogander@unikie.com wrote:
>> net/core/net-sysfs.c | 21 ++++++++++++++++-----
>> 1 file changed, 16 insertions(+), 5 deletions(-)
>>
>> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
>> index 865ba6ca16eb..72ecad583953 100644
>> --- a/net/core/net-sysfs.c
>> +++ b/net/core/net-sysfs.c
>> @@ -1626,6 +1626,12 @@ static void netdev_release(struct device *d)
>> {
>> struct net_device *dev = to_net_dev(d);
>>
>> + /* Triggered by an error clean-up (put_device) during
>> + * initialization.
>> + */
>> + if (dev->reg_state == NETREG_UNINITIALIZED)
>> + return;
>> +
>
> Are you sure about this? What about the memory involved here, what will
> free that?
In net/core/dev.c:free_netdev:
/* Compatibility with error handling in drivers */
if (dev->reg_state == NETREG_UNINITIALIZED) {
netdev_freemem(dev);
return;
}
I.e. driver is expected calling free_netdev in case of error and freeing
of device structure is done there. This brings up the question wether
put_device should be actually called in free_netdev also in error case?
Maybe that would be more correct as this free_netdev exists.
BR,
Jouni Högander
next prev parent reply other threads:[~2019-11-18 9:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-15 12:24 [PATCH] net-sysfs: Fix reference count leak jouni.hogander
2019-11-15 15:24 ` Greg Kroah-Hartman
2019-11-18 9:25 ` Jouni Högander [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-11-18 11:25 jouni.hogander
2019-11-18 11:33 ` Greg Kroah-Hartman
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=87tv718rke.fsf@unikie.com \
--to=jouni.hogander@unikie.com \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=lukas.bulwahn@gmail.com \
--cc=netdev@vger.kernel.org \
/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).