netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: wanghai26@huawei.com
Cc: idosch@mellanox.com, alexander.h.duyck@intel.com,
	tyhicks@canonical.com, f.fainelli@gmail.com,
	amritha.nambiar@intel.com, joe@perches.com,
	dmitry.torokhov@gmail.com, andriy.shevchenko@linux.intel.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] net-sysfs: Fix memory leak in netdev_register_kobject
Date: Thu, 21 Mar 2019 13:39:44 -0700 (PDT)	[thread overview]
Message-ID: <20190321.133944.1484834118085536102.davem@davemloft.net> (raw)
In-Reply-To: <20190320182505.18642-1-wanghai26@huawei.com>

From: Wang Hai <wanghai26@huawei.com>
Date: Wed, 20 Mar 2019 14:25:05 -0400

> When registering struct net_device, it will call
> 	register_netdevice ->
> 		netdev_register_kobject ->
> 			device_initialize(dev);
> 			dev_set_name(dev, "%s", ndev->name)
> 			device_add(dev)
> 			register_queue_kobjects(ndev)
> 
> In netdev_register_kobject(), if device_add(dev) or
> register_queue_kobjects(ndev) failed. Register_netdevice()
> will return error, causing netdev_freemem(ndev) to be
> called to free net_device, however put_device(&dev->dev)->..->
> kobject_cleanup() won't be called, resulting in a memory leak.
> 
> syzkaller report this:
 ...
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Fixes: 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array")
> Signed-off-by: Wang Hai <wanghai26@huawei.com>

Applied and queued up for -stable.

      parent reply	other threads:[~2019-03-21 20:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 18:25 [PATCH v3] net-sysfs: Fix memory leak in netdev_register_kobject Wang Hai
2019-03-20  9:41 ` Andy Shevchenko
2019-03-20 15:34 ` Stephen Hemminger
2019-03-21 20:39 ` David Miller [this message]

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=20190321.133944.1484834118085536102.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=alexander.h.duyck@intel.com \
    --cc=amritha.nambiar@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dmitry.torokhov@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=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 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).