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

From: Jouni HÃgander
Date: Fri Nov 15 2019 - 05:32:36 EST


Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> 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