Re: [PATCH 2/2] net-sysfs: Fix memory leak in netdev_register_kobject

From: wanghai (M)
Date: Fri Apr 12 2019 - 09:34:40 EST



在 2019/4/12 21:20, Andy Shevchenko 写道:
On Fri, Apr 12, 2019 at 06:03:27AM -0700, Eric Dumazet wrote:
On 04/12/2019 01:36 PM, Wang Hai wrote:
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
which is alloced by dev_set_name()



Having two patches with exact same title is rather confusing for bug trackers.

Instead of revert + another_patch, why not just send a cumulative fix ?
The second patch is a reincarnation of the first version of the fix which has
been discussed as not a correct approach. But revert should be applied sooner
as the original commit brought a regression.

Thanks for letting me know. Now should I resend a separate revert, or do you just review the first patch?