Re: [PATCH] net-sysfs: Fix memory leak in netdev_register_kobject
From: Andy Shevchenko
Date: Tue Mar 19 2019 - 06:30:45 EST
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@xxxxxxxxxx> 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
OK, that's true, but your patch is wrong.
See error handling in device_create_groups_vargs() for example.
With Best Regards,