Re: [PATCH] drivers/base: Fix memory leak in error paths

Jouni Högander
2019-11-15T10:32:36Z

Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:

>>
>> Ok, did some more debugging on
>> this. net/core/net-sysfs.c:netdev_register_kobject is doing
>> device_initialize(dev). This is in
>> drivers/base/core.c:device_initialize:
>>
>> * NOTE: Use put_device() to give up your reference instead of freeing
>> * @dev directly once you have called this function.
>>
>> My understanding is that remaining reference on error path is taken by
>> device_initialize and as instructed in the note above it should be given
>> up using put_device?
>
> Yes, that is correct.
>
>> Tested this and it's fixing the memory leak I found in my Syzkaller
>> exercise. Addition to that it seems to be fixing also this one:
>>
>> https://syzkaller.appspot.com/bug?id=f5f4af9fb9ffb3112ad6e30f717f769decdccdfc
>
> Great! Care to submit a patch for this?

I will submit another patch and Cc you there. This patch should be ignored.

BR,

Jouni Högander