lkml.org 
[lkml]   [2019]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] net-sysfs: Fix memory leak in netdev_register_kobject
On Tue, Mar 19, 2019 at 11:19:24AM +0800, wanghai (M) wrote:
>
> 在 2019/3/19 0:19, Andy Shevchenko 写道:
> > On Mon, Mar 18, 2019 at 08:57:24AM -0700, Stephen Hemminger wrote:
> > > On Tue, 19 Mar 2019 01:06:57 -0400
> > > Wang Hai <wanghai26@huawei.com> wrote:

> > > 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


\
 
 \ /
  Last update: 2019-03-19 11:31    [W:0.111 / U:0.740 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site