Thread (1 message) 1 message, 1 author, 2019-03-19

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

flat view

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2019-03-19 10:30:45
Also in: lkml

On Tue, Mar 19, 2019 at 11:19:24AM +0800, wanghai (M) wrote:
在 2019/3/19 0:19, Andy Shevchenko 写道:
quoted
On Mon, Mar 18, 2019 at 08:57:24AM -0700, Stephen Hemminger wrote:
quoted
On Tue, 19 Mar 2019 01:06:57 -0400
Wang Hai [off-list ref] wrote:
quoted
quoted
This looks a bug in device_add() not here.
In general, it is better for an api to clean up after itself.
Since dev->kobj.name is created in device_add and normally freed
in device_del; why is device_add leaving it behind?
It's more likely the bug in syzkaller.

Look at the kobject_cleanup() last lines of code...
If device_add(dev) or register_queue_kobjects(ndev) fails,
In register_netdevice(), dev-> reg_state = NETREG_UNINITIALIZED and returns
an error, causing put_device(&dev-> dev) -> ..-> kobject_cleanup() not to be
called.
OK, that's true, but your patch is wrong.
See error handling in device_create_groups_vargs() for example.

-- 
With Best Regards,
Andy Shevchenko

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help