All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: "wanghai (M)" <wanghai26@huawei.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	davem@davemloft.net, idosch@mellanox.com, eric.dumazet@gmail.com,
	alexander.h.duyck@intel.com, tyhicks@canonical.com,
	f.fainelli@gmail.com, amritha.nambiar@intel.com, joe@perches.com,
	dmitry.torokhov@gmail.com, stephen@networkplumber.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] net-sysfs: Fix memory leak in netdev_register_kobject
Date: Fri, 12 Apr 2019 13:50:52 +0100	[thread overview]
Message-ID: <20190412125052.GJ2217@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1c9542c4-08ba-24e6-6bb3-1aecc9741eec@huawei.com>

On Fri, Apr 12, 2019 at 08:08:32PM +0800, wanghai (M) wrote:
> 
> 在 2019/4/12 16:38, Andy Shevchenko 写道:
> > On Fri, Apr 12, 2019 at 04:36:34PM -0400, Wang Hai wrote:
> > 
> > > +error_register:
> > > +	device_del(dev);
> > > +error_device_add:
> > > +	kfree_const(dev->kobj.name);
> > >   	return error;
> > When put_device() will be called on this it will go to double free (in case of
> > dynamically allocated dev->kobj.name.
> > 
> > Al Viro and me suggested earlier that the correct fix is to call put_device()
> > in a places where it is appropriate.
> Thanks. I'll take a closer look at the code to see when it's time to call
> put_device(). It's really not easy to fix.

Depends upon the driver, obviously...  Note that if it's a built-in
with device never destroyed, that allocation is no leak at all -
reference to the object remains around.

  reply	other threads:[~2019-04-12 12:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-12 20:36 [PATCH 0/2] net-sysfs: revert wrong bugfix and re-fix Wang Hai
2019-04-12 20:36 ` [PATCH 1/2] Revert "net-sysfs: Fix memory leak in netdev_register_kobject" Wang Hai
2019-04-12  8:38   ` Andy Shevchenko
2019-04-15 20:10   ` David Miller
2019-04-12 20:36 ` [PATCH 2/2] net-sysfs: Fix memory leak in netdev_register_kobject Wang Hai
2019-04-12  8:38   ` Andy Shevchenko
2019-04-12 12:08     ` wanghai (M)
2019-04-12 12:50       ` Al Viro [this message]
2019-04-12 13:03   ` Eric Dumazet
2019-04-12 13:20     ` Andy Shevchenko
2019-04-12 13:33       ` wanghai (M)
2019-04-12 13:28     ` wanghai (M)

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=20190412125052.GJ2217@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=alexander.h.duyck@intel.com \
    --cc=amritha.nambiar@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=dmitry.torokhov@gmail.com \
    --cc=eric.dumazet@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=idosch@mellanox.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=tyhicks@canonical.com \
    --cc=wanghai26@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.