lkml.org 
[lkml]   [2019]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 3/3] net-sysfs: Fix error path for kobject_init_and_add()
From
Date

在 2019/5/1 0:11, Andy Shevchenko 写道:
> On Tue, Apr 30, 2019 at 10:28:17AM +1000, Tobin C. Harding wrote:
>> Currently error return from kobject_init_and_add() is not followed by a
>> call to kobject_put(). This means there is a memory leak.
>>
>> Add call to kobject_put() in error path of kobject_init_and_add().
> It's not obvious to me if this will help to fix what is stated in the
> (reverted) commit 6b70fc94afd1 ("net-sysfs: Fix memory leak in
> netdev_register_kobject")?
>
> If so, perhaps we need to tell syzkaller guys about this.
Thanks for reminding. It seems that the bug has not been completely fixed.

in netdev_register_kobject():

1746         error = device_add(dev);
1747         if (error)
1748                 return error;
1749
1750         error = register_queue_kobjects(ndev);
1751         if (error) {
1752                 device_del(dev);
1753                 return error;
1754         }

This only fixes a memory leak after a failure in
register_queue_kobjects(). If device_add() fails, kobject_put() still
cann't be called, and the memory leak still exists.

\
 
 \ /
  Last update: 2019-05-08 17:00    [W:0.070 / U:0.780 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site